From ebbbca98fab810587787683dce66e8cb8168eabb Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 29 Apr 2022 16:48:55 +0100 Subject: [PATCH] LibGUI: Run TextEditor::on_change callback immediately This is the only Widget that ran its callback in deferred_invoke(). It seems to be a holdover from when syntax-highlighting ran whenever the text changed, but that has not been true since bec2b3086c195e50f233e01f7ab935ba15ac843e. Running the callback immediately has no obvious downsides, but does make it a lot easier to reason about. (I might have spent an hour confused as to why things were happening in the wrong order...) --- Userland/Libraries/LibGUI/TextEditor.cpp | 10 ++-------- Userland/Libraries/LibGUI/TextEditor.h | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp index 31d76c82d4..9565991a8a 100644 --- a/Userland/Libraries/LibGUI/TextEditor.cpp +++ b/Userland/Libraries/LibGUI/TextEditor.cpp @@ -1576,14 +1576,8 @@ void TextEditor::did_change(AllowCallback allow_callback) recompute_all_visual_lines(); hide_autocomplete_if_needed(); m_needs_rehighlight = true; - if (!m_has_pending_change_notification) { - m_has_pending_change_notification = true; - deferred_invoke([this, allow_callback] { - m_has_pending_change_notification = false; - if (on_change && allow_callback == AllowCallback::Yes) - on_change(); - }); - } + if (on_change && allow_callback == AllowCallback::Yes) + on_change(); } void TextEditor::set_mode(const Mode mode) { diff --git a/Userland/Libraries/LibGUI/TextEditor.h b/Userland/Libraries/LibGUI/TextEditor.h index be582cabab..6f8e4ac2f1 100644 --- a/Userland/Libraries/LibGUI/TextEditor.h +++ b/Userland/Libraries/LibGUI/TextEditor.h @@ -361,7 +361,6 @@ private: bool m_ruler_visible { false }; bool m_gutter_visible { false }; bool m_needs_rehighlight { false }; - bool m_has_pending_change_notification { false }; bool m_automatic_indentation_enabled { false }; WrappingMode m_wrapping_mode { WrappingMode::NoWrap }; bool m_visualize_trailing_whitespace { true };