diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2018-09-12 14:59:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 14:59:34 +0200 |
commit | 82a0e752dfd1346fba4fa20454065891f91e48cf (patch) | |
tree | 917dda13d11d7b53195140d5715548eebf1bab02 /scene/gui | |
parent | c4311b62c4eae8dd4ec614dcacaba48513284c85 (diff) | |
parent | dd6074010c2afe5a1f9f23d12e900a8ea12584b0 (diff) |
Merge pull request #21877 from DualMatrix/richlabel
Fixed the remove_line function in richtextlabel. It was totally broken
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/rich_text_label.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index b1c44aea3c..1e281471a6 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -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; } |