Skip to content

Commit ebbbca9

Browse files
AtkinsSJawesomekling
authored andcommitted
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 bec2b30. 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...)
1 parent 0836912 commit ebbbca9

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

Userland/Libraries/LibGUI/TextEditor.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,14 +1576,8 @@ void TextEditor::did_change(AllowCallback allow_callback)
15761576
recompute_all_visual_lines();
15771577
hide_autocomplete_if_needed();
15781578
m_needs_rehighlight = true;
1579-
if (!m_has_pending_change_notification) {
1580-
m_has_pending_change_notification = true;
1581-
deferred_invoke([this, allow_callback] {
1582-
m_has_pending_change_notification = false;
1583-
if (on_change && allow_callback == AllowCallback::Yes)
1584-
on_change();
1585-
});
1586-
}
1579+
if (on_change && allow_callback == AllowCallback::Yes)
1580+
on_change();
15871581
}
15881582
void TextEditor::set_mode(const Mode mode)
15891583
{

Userland/Libraries/LibGUI/TextEditor.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ class TextEditor
361361
bool m_ruler_visible { false };
362362
bool m_gutter_visible { false };
363363
bool m_needs_rehighlight { false };
364-
bool m_has_pending_change_notification { false };
365364
bool m_automatic_indentation_enabled { false };
366365
WrappingMode m_wrapping_mode { WrappingMode::NoWrap };
367366
bool m_visualize_trailing_whitespace { true };

0 commit comments

Comments
 (0)