diff options
author | Thaddeus Crews <repiteo@outlook.com> | 2024-11-15 10:42:33 -0600 |
---|---|---|
committer | Thaddeus Crews <repiteo@outlook.com> | 2024-11-15 10:42:33 -0600 |
commit | af3fb0a2b84b9d624afef45f68c267528046e199 (patch) | |
tree | df33e450d44bf61ac5fd834991cdb6c7d5dbcd1e /scene | |
parent | 934549e2a0822a90ef07a727b95543affaf5c57a (diff) | |
parent | a1a5c87f9e640cfe09edb58ed9cabd17afe5e7e9 (diff) | |
download | redot-engine-af3fb0a2b84b9d624afef45f68c267528046e199.tar.gz |
Merge pull request #86085 from TheSofox/text-undo-cleanup
Cleanup in undo in `TextEdit` and `LineEdit`
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/line_edit.cpp | 14 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 2 |
2 files changed, 6 insertions, 10 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 3f979f7c20..b7c7326172 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1452,13 +1452,12 @@ void LineEdit::undo() { return; } + if (!has_undo()) { + return; + } + if (undo_stack_pos == nullptr) { - if (undo_stack.size() <= 1) { - return; - } undo_stack_pos = undo_stack.back(); - } else if (undo_stack_pos == undo_stack.front()) { - return; } deselect(); @@ -1479,10 +1478,7 @@ void LineEdit::redo() { return; } - if (undo_stack_pos == nullptr) { - return; - } - if (undo_stack_pos == undo_stack.back()) { + if (!has_redo()) { return; } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 05e9b84bfa..b8bb17eb2a 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4175,7 +4175,7 @@ void TextEdit::redo() { } _push_current_op(); - if (undo_stack_pos == nullptr) { + if (!has_redo()) { return; // Nothing to do. } |