diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2023-01-12 17:29:08 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-13 13:37:19 +0100 |
commit | a5ff6769f5eece607b45dde102e5af59a0062ece (patch) | |
tree | 20b224e45a6094e0a41df53e9fee6878e4592bdb /Userland/Libraries/LibGUI/TextDocument.h | |
parent | 7164b2f7580b1cde264c01896c9914c69512b57e (diff) | |
download | serenity-a5ff6769f5eece607b45dde102e5af59a0062ece.zip |
LibGUI: Make undo work for TextDocument ReplaceAllTextCommand
The undo code here was just replacing the new text with the new text.
Now we actually save the old text and use that instead. :^)
Diffstat (limited to 'Userland/Libraries/LibGUI/TextDocument.h')
-rw-r--r-- | Userland/Libraries/LibGUI/TextDocument.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/TextDocument.h b/Userland/Libraries/LibGUI/TextDocument.h index 912354f04d..3bae9594fa 100644 --- a/Userland/Libraries/LibGUI/TextDocument.h +++ b/Userland/Libraries/LibGUI/TextDocument.h @@ -270,17 +270,18 @@ private: class ReplaceAllTextCommand final : public GUI::TextDocumentUndoCommand { public: - ReplaceAllTextCommand(GUI::TextDocument& document, DeprecatedString const& text, GUI::TextRange const& range, DeprecatedString const& action_text); + ReplaceAllTextCommand(GUI::TextDocument& document, DeprecatedString const& new_text, GUI::TextRange const& range, DeprecatedString const& action_text); virtual ~ReplaceAllTextCommand() = default; void redo() override; void undo() override; bool merge_with(GUI::Command const&) override; DeprecatedString action_text() const override; - DeprecatedString const& text() const { return m_text; } + DeprecatedString const& text() const { return m_new_text; } TextRange const& range() const { return m_range; } private: - DeprecatedString m_text; + DeprecatedString m_original_text; + DeprecatedString m_new_text; GUI::TextRange m_range; DeprecatedString m_action_text; }; |