Skip to content

Commit 51d7d6b

Browse files
committed
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.
2 parents cd66343 + d22419b commit 51d7d6b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

scene/gui/text_edit.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ void TextEdit::Text::clear() {
332332

333333
max_line_width_dirty = true;
334334
max_line_height_dirty = true;
335+
total_visible_line_count = 0;
335336

336337
Line line;
337338
line.gutters.resize(gutter_count);
@@ -421,6 +422,10 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) {
421422

422423
for (int i = p_from_line; i < p_to_line; i++) {
423424
const Line &text_line = text[i];
425+
if (text_line.hidden) {
426+
continue;
427+
}
428+
424429
if (text_line.height == max_line_height) {
425430
max_line_height_dirty = true;
426431
}
@@ -435,6 +440,8 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) {
435440
text.write[(i - diff) + 1] = text[i + 1];
436441
}
437442
text.resize(text.size() - diff);
443+
444+
ERR_FAIL_COND(total_visible_line_count < 0); // BUG
438445
}
439446

440447
void TextEdit::Text::add_gutter(int p_at) {

0 commit comments

Comments
 (0)