浏览代码

Merge pull request #59897 from timothyqiu/undo-select

Consider chained operation when selecting text in `TextEdit::undo()`
Rémi Verschelde 3 年之前
父节点
当前提交
479143ab2a
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      scene/gui/text_edit.cpp

+ 4 - 3
scene/gui/text_edit.cpp

@@ -3486,9 +3486,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) {
@@ -3504,6 +3501,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) {
 		set_caret_line(undo_stack_pos->get().to_line, false);
 		set_caret_line(undo_stack_pos->get().to_line, false);