浏览代码

Merge pull request #86085 from TheSofox/text-undo-cleanup

Cleanup in undo in `TextEdit` and `LineEdit`
Thaddeus Crews 11 月之前
父节点
当前提交
af3fb0a2b8
共有 2 个文件被更改,包括 6 次插入10 次删除
  1. 5 9
      scene/gui/line_edit.cpp
  2. 1 1
      scene/gui/text_edit.cpp

+ 5 - 9
scene/gui/line_edit.cpp

@@ -1452,13 +1452,12 @@ void LineEdit::undo() {
 		return;
 		return;
 	}
 	}
 
 
+	if (!has_undo()) {
+		return;
+	}
+
 	if (undo_stack_pos == nullptr) {
 	if (undo_stack_pos == nullptr) {
-		if (undo_stack.size() <= 1) {
-			return;
-		}
 		undo_stack_pos = undo_stack.back();
 		undo_stack_pos = undo_stack.back();
-	} else if (undo_stack_pos == undo_stack.front()) {
-		return;
 	}
 	}
 
 
 	deselect();
 	deselect();
@@ -1479,10 +1478,7 @@ void LineEdit::redo() {
 		return;
 		return;
 	}
 	}
 
 
-	if (undo_stack_pos == nullptr) {
-		return;
-	}
-	if (undo_stack_pos == undo_stack.back()) {
+	if (!has_redo()) {
 		return;
 		return;
 	}
 	}
 
 

+ 1 - 1
scene/gui/text_edit.cpp

@@ -4175,7 +4175,7 @@ void TextEdit::redo() {
 	}
 	}
 	_push_current_op();
 	_push_current_op();
 
 
-	if (undo_stack_pos == nullptr) {
+	if (!has_redo()) {
 		return; // Nothing to do.
 		return; // Nothing to do.
 	}
 	}