From 2ef4fbc5c199607a6b9ca6d41c88c6d270d91da8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 8 May 2021 13:48:07 +0200 Subject: [PATCH] Revert "LibGUI: Fix undo stack reporting wrong modified state" This reverts commit 0b7e19e2bb34cceb340607f0b7f76b338d78767e. Let's reverse the direction of the undo stack to fix the confusion. --- Userland/Libraries/LibGUI/UndoStack.cpp | 16 ++++++---------- Userland/Libraries/LibGUI/UndoStack.h | 2 -- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Userland/Libraries/LibGUI/UndoStack.cpp b/Userland/Libraries/LibGUI/UndoStack.cpp index 0a6fd094da..47e584bbb5 100644 --- a/Userland/Libraries/LibGUI/UndoStack.cpp +++ b/Userland/Libraries/LibGUI/UndoStack.cpp @@ -92,12 +92,16 @@ void UndoStack::finalize_current_combo() void UndoStack::set_current_unmodified() { - m_clean_index = non_empty_stack_index(); + // Skip empty container + if (can_undo() && m_stack[m_stack_index].commands.is_empty()) + m_clean_index = m_stack_index + 1; + else + m_clean_index = m_stack_index; } bool UndoStack::is_current_modified() const { - return !m_clean_index.has_value() || non_empty_stack_index() != m_clean_index.value(); + return !m_clean_index.has_value() || m_stack_index != m_clean_index.value(); } void UndoStack::clear() @@ -107,12 +111,4 @@ void UndoStack::clear() m_clean_index.clear(); } -size_t UndoStack::non_empty_stack_index() const -{ - if (can_undo() && m_stack[m_stack_index].commands.is_empty()) - return m_stack_index + 1; - else - return m_stack_index; -} - } diff --git a/Userland/Libraries/LibGUI/UndoStack.h b/Userland/Libraries/LibGUI/UndoStack.h index db3065f183..51b5e00436 100644 --- a/Userland/Libraries/LibGUI/UndoStack.h +++ b/Userland/Libraries/LibGUI/UndoStack.h @@ -32,8 +32,6 @@ public: void clear(); private: - size_t non_empty_stack_index() const; - struct Combo { NonnullOwnPtrVector commands; };