diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-12 12:13:20 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-12 12:13:20 -0600 |
commit | 51d7d6b5b7f22c97cc234dd538e2299a7158e5ca (patch) | |
tree | 27cafc84ac7ff5e863808d3e417555d16fa84f3f /scene/gui | |
parent | cd66343c709a89db73a53fde71265edb54b88f03 (diff) | |
parent | d22419b45372a931c170041f29d85b2ba5abea76 (diff) | |
download | redot-engine-51d7d6b5b7f22c97cc234dd538e2299a7158e5ca.tar.gz |
Merge pull request #98678 from Daylily-Zeleen/daylily-zeleen/fix_text_edit
Fix `total_visible_line_count` calculation when removing and clearing `TextEdit`'s text.
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/text_edit.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index b1918ff23f..699277ba41 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -332,6 +332,7 @@ void TextEdit::Text::clear() { max_line_width_dirty = true; max_line_height_dirty = true; + total_visible_line_count = 0; Line line; line.gutters.resize(gutter_count); @@ -421,6 +422,10 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) { for (int i = p_from_line; i < p_to_line; i++) { const Line &text_line = text[i]; + if (text_line.hidden) { + continue; + } + if (text_line.height == max_line_height) { max_line_height_dirty = true; } @@ -435,6 +440,8 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) { text.write[(i - diff) + 1] = text[i + 1]; } text.resize(text.size() - diff); + + ERR_FAIL_COND(total_visible_line_count < 0); // BUG } void TextEdit::Text::add_gutter(int p_at) { |