Merge pull request #47690 from nekomatata/textedit-fix-cursor-update-3.x
[3.x] Fix TextEdit cursor update when adding or deleting text
This commit is contained in:
commit
76a3c72a1d
|
@ -2054,7 +2054,7 @@ void TextEdit::backspace_at_cursor() {
|
|||
}
|
||||
}
|
||||
|
||||
cursor_set_line(prev_line, true, true);
|
||||
cursor_set_line(prev_line, false, true);
|
||||
cursor_set_column(prev_column);
|
||||
}
|
||||
|
||||
|
@ -2933,7 +2933,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
|
|||
selection.active = false;
|
||||
update();
|
||||
_remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
|
||||
cursor_set_line(selection.from_line, true, false);
|
||||
cursor_set_line(selection.from_line, false, false);
|
||||
cursor_set_column(selection.from_column);
|
||||
update();
|
||||
}
|
||||
|
@ -4282,7 +4282,7 @@ void TextEdit::_insert_text_at_cursor(const String &p_text) {
|
|||
int new_column, new_line;
|
||||
_insert_text(cursor.line, cursor.column, p_text, &new_line, &new_column);
|
||||
_update_scrollbars();
|
||||
cursor_set_line(new_line);
|
||||
cursor_set_line(new_line, false);
|
||||
cursor_set_column(new_column);
|
||||
|
||||
update();
|
||||
|
@ -4878,7 +4878,7 @@ int TextEdit::get_column_x_offset(int p_char, String p_str) const {
|
|||
|
||||
void TextEdit::insert_text_at_cursor(const String &p_text) {
|
||||
if (selection.active) {
|
||||
cursor_set_line(selection.from_line);
|
||||
cursor_set_line(selection.from_line, false);
|
||||
cursor_set_column(selection.from_column);
|
||||
|
||||
_remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
|
||||
|
@ -5337,7 +5337,7 @@ void TextEdit::cut() {
|
|||
OS::get_singleton()->set_clipboard(clipboard);
|
||||
|
||||
_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_line(selection.from_line, false); // Set afterwards else it causes the view to be offset.
|
||||
cursor_set_column(selection.from_column);
|
||||
|
||||
selection.active = false;
|
||||
|
@ -5369,7 +5369,7 @@ void TextEdit::paste() {
|
|||
selection.active = false;
|
||||
selection.selecting_mode = Selection::MODE_NONE;
|
||||
_remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
|
||||
cursor_set_line(selection.from_line);
|
||||
cursor_set_line(selection.from_line, false);
|
||||
cursor_set_column(selection.from_column);
|
||||
|
||||
} else if (!cut_copy_line.empty() && cut_copy_line == clipboard) {
|
||||
|
@ -6224,11 +6224,11 @@ void TextEdit::undo() {
|
|||
|
||||
_update_scrollbars();
|
||||
if (undo_stack_pos->get().type == TextOperation::TYPE_REMOVE) {
|
||||
cursor_set_line(undo_stack_pos->get().to_line);
|
||||
cursor_set_line(undo_stack_pos->get().to_line, false);
|
||||
cursor_set_column(undo_stack_pos->get().to_column);
|
||||
_cancel_code_hint();
|
||||
} else {
|
||||
cursor_set_line(undo_stack_pos->get().from_line);
|
||||
cursor_set_line(undo_stack_pos->get().from_line, false);
|
||||
cursor_set_column(undo_stack_pos->get().from_column);
|
||||
}
|
||||
update();
|
||||
|
@ -6260,7 +6260,7 @@ void TextEdit::redo() {
|
|||
}
|
||||
|
||||
_update_scrollbars();
|
||||
cursor_set_line(undo_stack_pos->get().to_line);
|
||||
cursor_set_line(undo_stack_pos->get().to_line, false);
|
||||
cursor_set_column(undo_stack_pos->get().to_column);
|
||||
undo_stack_pos = undo_stack_pos->next();
|
||||
update();
|
||||
|
|
Loading…
Reference in New Issue