summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TextEditor.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-08 13:40:33 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-08 13:49:34 +0200
commit2905e10513859de9d0fce4e7f18a99bf1ecb01a7 (patch)
tree5c3e0a641d69ac3932b282e0dcda287fc6dcf94a /Userland/Libraries/LibGUI/TextEditor.cpp
parentee19f7c0aac48b1ca6527413552fc05a4fe16710 (diff)
downloadserenity-2905e10513859de9d0fce4e7f18a99bf1ecb01a7.zip
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.
Diffstat (limited to 'Userland/Libraries/LibGUI/TextEditor.cpp')
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index bd9b9754e9..7e1582562d 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -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()