Browse Source

Consider chained operation when selecting text in TextEdit::undo()

(cherry picked from commit 8cefbfcf432ef6ed3879ee60bf500b52149f3e01)
Haoyu Qiu 3 years ago
parent
commit
1d476d7737
1 changed files with 4 additions and 3 deletions
  1. 4 3
      scene/gui/text_edit.cpp

+ 4 - 3
scene/gui/text_edit.cpp

@@ -6474,9 +6474,6 @@ void TextEdit::undo() {
 
 
 	TextOperation op = undo_stack_pos->get();
 	TextOperation op = undo_stack_pos->get();
 	_do_text_op(op, true);
 	_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;
 	current_op.version = op.prev_version;
 	if (undo_stack_pos->get().chain_backward) {
 	if (undo_stack_pos->get().chain_backward) {
@@ -6492,6 +6489,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();
 	_update_scrollbars();
 	if (undo_stack_pos->get().type == TextOperation::TYPE_REMOVE) {
 	if (undo_stack_pos->get().type == TextOperation::TYPE_REMOVE) {
 		cursor_set_line(undo_stack_pos->get().to_line, false);
 		cursor_set_line(undo_stack_pos->get().to_line, false);