1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:58:13 +00:00

LibGUI+TextEditor: Make TextDocument modified state track undo stack

This was quite unreliable before. Changes to the undo stack's modified
state are now reflected in the document's modified state, and the
GUI::TextEditor widget has its undo/redo actions updated automatically.

UndoStack is still a bit hard to understand due to the lazy coalescing
of commands, and that's something we should improve upon (e.g with more
explicit, incremental command merging.) But for now, this is a nice
improvement and undo/redo finally behaves in a way that feels natural.
This commit is contained in:
Andreas Kling 2021-05-08 13:40:33 +02:00
parent ee19f7c0aa
commit 2905e10513
4 changed files with 23 additions and 4 deletions

View file

@ -1638,6 +1638,11 @@ void TextEditor::document_did_update_undo_stack()
{
m_undo_action->set_enabled(can_undo());
m_redo_action->set_enabled(can_redo());
// FIXME: This is currently firing more often than it should.
// Ideally we'd only send this out when the undo stack modified state actually changes.
if (on_modified_change)
on_modified_change(document().is_modified());
}
void TextEditor::document_did_set_text()