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

Cleanup in undo in `TextEdit` and `LineEdit`
This commit is contained in:
Thaddeus Crews 2024-11-15 10:42:33 -06:00
commit af3fb0a2b8
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84
2 changed files with 7 additions and 11 deletions

View File

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

View File

@ -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.
} }