summaryrefslogtreecommitdiff
path: root/scene/gui/rich_text_label.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui/rich_text_label.cpp')
-rw-r--r--scene/gui/rich_text_label.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index a5f9bea1b1..1e281471a6 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -29,8 +29,8 @@
/*************************************************************************/
#include "rich_text_label.h"
-#include "os/keyboard.h"
-#include "os/os.h"
+#include "core/os/keyboard.h"
+#include "core/os/os.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@@ -1423,18 +1423,28 @@ bool RichTextLabel::remove_line(const int p_line) {
if (p_line >= current_frame->lines.size() || p_line < 0)
return false;
- int lines = p_line * 2;
+ int i = 0;
+ while (i < current->subitems.size() && current->subitems[i]->line < p_line) {
+ i++;
+ }
- if (current->subitems[lines]->type != ITEM_NEWLINE)
- _remove_item(current->subitems[lines], current->subitems[lines]->line, lines);
+ bool was_newline = false;
+ while (i < current->subitems.size()) {
+ was_newline = current->subitems[i]->type == ITEM_NEWLINE;
+ _remove_item(current->subitems[i], current->subitems[i]->line, p_line);
+ if (was_newline)
+ break;
+ }
- _remove_item(current->subitems[lines], current->subitems[lines]->line, lines);
+ if (!was_newline) {
+ current_frame->lines.remove(p_line);
+ }
- if (p_line == 0) {
+ if (p_line == 0 && current->subitems.size() > 0)
main->lines.write[0].from = main;
- }
main->first_invalid_line = 0;
+
return true;
}