Fixed offset view when removing text, issue 10529

This commit is contained in:
Paulb23 2017-08-27 18:07:28 +01:00
parent 73d2504fce
commit ae26f8e015

View file

@ -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();