1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:47:44 +00:00

LibLine: Avoid refreshing the entire line when inserting at the end

This patchset allows the editor to avoid redrawing the entire line when
the changes cause no unrecoverable style updates, and are at the end of
the line (this applies to most normal typing situations).
Cases that this does not resolve:
- When the cursor is not at the end of the buffer
- When a display refresh changes the styles on the already-drawn parts
  of the line
- When the prompt has not yet been drawn, or has somehow changed

Fixes #5296.
This commit is contained in:
AnotherTest 2021-02-20 21:33:13 +03:30 committed by Andreas Kling
parent 101c6b01ed
commit 074e2ffdfd
5 changed files with 151 additions and 41 deletions

View file

@ -410,8 +410,9 @@ private:
size_t m_cursor { 0 };
size_t m_drawn_cursor { 0 };
size_t m_drawn_end_of_line_offset { 0 };
size_t m_inline_search_cursor { 0 };
size_t m_chars_inserted_in_the_middle { 0 };
size_t m_chars_touched_in_the_middle { 0 };
size_t m_times_tab_pressed { 0 };
size_t m_num_columns { 0 };
size_t m_num_lines { 1 };
@ -470,11 +471,14 @@ private:
};
InputState m_state { InputState::Free };
HashMap<u32, HashMap<u32, Style>> m_spans_starting;
HashMap<u32, HashMap<u32, Style>> m_spans_ending;
struct Spans {
HashMap<u32, HashMap<u32, Style>> m_spans_starting;
HashMap<u32, HashMap<u32, Style>> m_spans_ending;
HashMap<u32, HashMap<u32, Style>> m_anchored_spans_starting;
HashMap<u32, HashMap<u32, Style>> m_anchored_spans_ending;
HashMap<u32, HashMap<u32, Style>> m_anchored_spans_starting;
HashMap<u32, HashMap<u32, Style>> m_anchored_spans_ending;
bool contains_up_to_offset(const Spans& other, size_t offset) const;
} m_drawn_spans, m_current_spans;
RefPtr<Core::Notifier> m_notifier;