From 964249a5b01792b080ba328856e0724b85065914 Mon Sep 17 00:00:00 2001 From: luiz Date: Sat, 14 Aug 2021 20:03:37 -0300 Subject: [PATCH] LibGUI: Fixes modified indicator behavior after saving Pior to this change when the user added text after having saved the file the Text Editor wouldn't enable the modified flag, unless this new text was a new line. This happened because the UndoStack was merging the Command added by the new text with the old text one, and when is_current_modified() was called, the m_stack_index would not have been incremented, and it would return false. In this change was added a condition to verify if the modified tag is active, and the merge is only done if the document is already modified. --- Userland/Libraries/LibGUI/UndoStack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/UndoStack.cpp b/Userland/Libraries/LibGUI/UndoStack.cpp index ea7aa2a125..11585e362d 100644 --- a/Userland/Libraries/LibGUI/UndoStack.cpp +++ b/Userland/Libraries/LibGUI/UndoStack.cpp @@ -62,7 +62,7 @@ void UndoStack::push(NonnullOwnPtr command) if (m_clean_index.has_value() && m_clean_index.value() > m_stack.size()) m_clean_index = {}; - if (!m_stack.is_empty()) { + if (!m_stack.is_empty() && is_current_modified()) { if (m_stack.last().merge_with(*command)) return; }