From 2aefcf5585ddbce53e3f632f06ad2abdce0619b7 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 5 Apr 2022 09:12:10 +0800 Subject: [PATCH] Consider chained operation when selecting text in TextEdit::undo() (cherry picked from commit 8cefbfcf432ef6ed3879ee60bf500b52149f3e01) --- scene/gui/text_edit.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index d667d4fd1..15606cc9c 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -6457,9 +6457,6 @@ void TextEdit::undo() { TextOperation op = undo_stack_pos->get(); _do_text_op(op, true); - if (op.type != TextOperation::TYPE_INSERT && (op.from_line != op.to_line || op.to_column != op.from_column + 1)) { - select(op.from_line, op.from_column, op.to_line, op.to_column); - } current_op.version = op.prev_version; if (undo_stack_pos->get().chain_backward) { @@ -6475,6 +6472,10 @@ void TextEdit::undo() { } } + if (op.type != TextOperation::TYPE_INSERT && (op.from_line != op.to_line || op.to_column != op.from_column + 1)) { + select(op.from_line, op.from_column, op.to_line, op.to_column); + } + _update_scrollbars(); if (undo_stack_pos->get().type == TextOperation::TYPE_REMOVE) { cursor_set_line(undo_stack_pos->get().to_line, false);