diff options
author | Paulb23 <p_batty@hotmail.co.uk> | 2017-08-27 18:07:28 +0100 |
---|---|---|
committer | Paulb23 <p_batty@hotmail.co.uk> | 2017-08-27 18:29:15 +0100 |
commit | ae26f8e015ff9e582aae888c7cdee697612e664c (patch) | |
tree | 74993b37ab105ec5c6c3db353b0a045b16a1d397 /scene/gui | |
parent | 73d2504fce8ac28c32704e8fdf53fc3425f4e193 (diff) |
Fixed offset view when removing text, issue 10529
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/text_edit.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index d585562dc6..58637ef72f 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -3190,6 +3190,11 @@ void TextEdit::adjust_viewport_to_cursor() { if (cursor.line < cursor.line_ofs) cursor.line_ofs = cursor.line; + if (cursor.line_ofs + visible_rows > text.size() && !scroll_past_end_of_file_enabled) { + cursor.line_ofs = text.size() - visible_rows; + v_scroll->set_value(text.size() - visible_rows); + } + int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]); if (cursor_x > (cursor.x_ofs + visible_width)) @@ -3662,10 +3667,10 @@ void TextEdit::cut() { String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); OS::get_singleton()->set_clipboard(clipboard); - cursor_set_line(selection.from_line); + _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); + cursor_set_line(selection.from_line); // set afterwards else it causes the view to be offset cursor_set_column(selection.from_column); - _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); selection.active = false; selection.selecting_mode = Selection::MODE_NONE; update(); |