diff options
Diffstat (limited to 'Userland/Libraries/LibGUI')
-rw-r--r-- | Userland/Libraries/LibGUI/TextDocument.cpp | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/UndoStack.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibGUI/UndoStack.h | 2 |
3 files changed, 9 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp index 6799e5c90d..27042d1696 100644 --- a/Userland/Libraries/LibGUI/TextDocument.cpp +++ b/Userland/Libraries/LibGUI/TextDocument.cpp @@ -41,6 +41,7 @@ TextDocument::~TextDocument() bool TextDocument::set_text(const StringView& text) { m_client_notifications_enabled = false; + m_undo_stack.clear(); m_spans.clear(); remove_all_lines(); diff --git a/Userland/Libraries/LibGUI/UndoStack.cpp b/Userland/Libraries/LibGUI/UndoStack.cpp index 7267c83bf4..7f32d3e4fb 100644 --- a/Userland/Libraries/LibGUI/UndoStack.cpp +++ b/Userland/Libraries/LibGUI/UndoStack.cpp @@ -80,4 +80,10 @@ void UndoStack::finalize_current_combo() m_stack.prepend(move(undo_commands_container)); } +void UndoStack::clear() +{ + m_stack.clear(); + m_stack_index = 0; +} + } diff --git a/Userland/Libraries/LibGUI/UndoStack.h b/Userland/Libraries/LibGUI/UndoStack.h index 0921d835a5..f854171c83 100644 --- a/Userland/Libraries/LibGUI/UndoStack.h +++ b/Userland/Libraries/LibGUI/UndoStack.h @@ -26,6 +26,8 @@ public: void finalize_current_combo(); + void clear(); + private: struct UndoCommandsContainer { NonnullOwnPtrVector<Command> m_undo_vector; |