1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

GTextEditor: Add a way to flush any pending on_change notifications

Since on_change handlers can alter the text document we're working on,
we have to make sure they've been run before we try looking at spans.
This fixes some flakiness when a paint happened before HackStudio had
a chance to re-highlight some C++ while editing it.

The design where clients of GTextEditor perform syntax highlighting in
the "arbitrary code execution" on_change callback is not very good.
We should find a way to move highlighting closer to the editor.
This commit is contained in:
Andreas Kling 2019-11-08 19:49:08 +01:00
parent c3c905aa6c
commit c16b1a515e
2 changed files with 22 additions and 4 deletions

View file

@ -160,6 +160,7 @@ private:
Rect visible_text_rect_in_inner_coordinates() const;
void recompute_all_visual_lines();
void ensure_cursor_is_valid();
void flush_pending_change_notification_if_needed();
class UndoCommand {
@ -233,7 +234,7 @@ private:
bool m_cursor_state { true };
bool m_in_drag_select { false };
bool m_ruler_visible { false };
bool m_have_pending_change_notification { false };
bool m_has_pending_change_notification { false };
bool m_automatic_indentation_enabled { false };
bool m_line_wrapping_enabled { false };
bool m_readonly { false };