diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-06-07 20:16:19 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-06-07 20:16:19 +0100 |
| commit | 03f8679e5c676c2f465833135b16000632e226a0 (patch) | |
| tree | 27340dad29301ab59e4602c7fb89e94362992c12 /src/input_handler.cc | |
| parent | b81500c0e4c5dac5c976fc5553658d9f009ddf00 (diff) | |
Only trigger PromptEvent::Change on idle
There is no need to trigger that event on every keystroke, we can
trigger it only when we hit the idle timeout, avoiding computations
when input keys are pasted.
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 8c0a7618..4f977876 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -698,6 +698,11 @@ public: [this](Timer& timer) { if (m_autoshowcompl and m_refresh_completion_pending) refresh_completions(CompletionFlags::Fast); + if (m_line_changed) + { + m_callback(m_line_editor.line(), PromptEvent::Change, context()); + m_line_changed = false; + } context().hooks().run_hook("PromptIdle", "", context()); }} { @@ -752,7 +757,7 @@ public: m_line_editor.insert(reg); display(); - m_callback(m_line_editor.line(), PromptEvent::Change, context()); + m_line_changed = true; } }, "Enter register name", register_doc); display(); @@ -766,7 +771,7 @@ public: { m_line_editor.insert(*cp); display(); - m_callback(m_line_editor.line(), PromptEvent::Change, context()); + m_line_changed = true; } }, "raw insert", "enter key to insert"); display(); @@ -867,7 +872,7 @@ public: } display(); - m_callback(line, PromptEvent::Change, context()); + m_line_changed = true; if (enabled()) // The callback might have disabled us m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context())); } @@ -950,6 +955,7 @@ private: void on_enabled() override { display(); + m_line_changed = false; m_callback(m_line_editor.line(), PromptEvent::Change, context()); m_idle_timer.set_next_date(Clock::now() + get_idle_timeout(context())); } @@ -971,6 +977,7 @@ private: bool m_prefix_in_completions = false; String m_prefix; LineEditor m_line_editor; + bool m_line_changed = false; PromptFlags m_flags; bool m_autoshowcompl; bool m_refresh_completion_pending = true; |
