mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:07:46 +00:00
LibGUI: Clear undo stack when opening a new document
This commit is contained in:
parent
88803b2e34
commit
67537bfc80
3 changed files with 9 additions and 0 deletions
|
@ -41,6 +41,7 @@ TextDocument::~TextDocument()
|
||||||
bool TextDocument::set_text(const StringView& text)
|
bool TextDocument::set_text(const StringView& text)
|
||||||
{
|
{
|
||||||
m_client_notifications_enabled = false;
|
m_client_notifications_enabled = false;
|
||||||
|
m_undo_stack.clear();
|
||||||
m_spans.clear();
|
m_spans.clear();
|
||||||
remove_all_lines();
|
remove_all_lines();
|
||||||
|
|
||||||
|
|
|
@ -80,4 +80,10 @@ void UndoStack::finalize_current_combo()
|
||||||
m_stack.prepend(move(undo_commands_container));
|
m_stack.prepend(move(undo_commands_container));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UndoStack::clear()
|
||||||
|
{
|
||||||
|
m_stack.clear();
|
||||||
|
m_stack_index = 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,8 @@ public:
|
||||||
|
|
||||||
void finalize_current_combo();
|
void finalize_current_combo();
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct UndoCommandsContainer {
|
struct UndoCommandsContainer {
|
||||||
NonnullOwnPtrVector<Command> m_undo_vector;
|
NonnullOwnPtrVector<Command> m_undo_vector;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue