From a1a5c87f9e640cfe09edb58ed9cabd17afe5e7e9 Mon Sep 17 00:00:00 2001 From: Sofox Date: Tue, 12 Dec 2023 17:51:53 +0000 Subject: Cleanup in undo in TextEdit and LineEdit --- scene/gui/line_edit.cpp | 14 +++++--------- scene/gui/text_edit.cpp | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'scene') diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 5ed1a9d5e3..55645e1138 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1208,13 +1208,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(); @@ -1234,10 +1233,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 5817f70343..ba8b0b9b23 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -4024,7 +4024,7 @@ void TextEdit::redo() { } _push_current_op(); - if (undo_stack_pos == nullptr) { + if (!has_redo()) { return; // Nothing to do. } -- cgit v1.2.3