diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2013-01-14 19:08:00 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2013-01-14 19:17:37 +0100 |
| commit | a1998dac7a0766202a953e137dd3ea061414a20f (patch) | |
| tree | 943f7ca92cb44f5bd1f06ad4f69ae8cf8416821c /src/input_handler.cc | |
| parent | 90eeb7b8a77a78a358234957624ea86cedc804f6 (diff) | |
InputHandler: use a timer for word completion instead of calling it at each insertion
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index d3cd8460..e411110d 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -3,6 +3,7 @@ #include "context.hh" #include "editor.hh" #include "register_manager.hh" +#include "event_manager.hh" #include "utf8.hh" #include <unordered_map> @@ -514,7 +515,12 @@ class Insert : public InputMode public: Insert(Context& context, InsertMode mode) : InputMode(context.input_handler()), - m_inserter(context.editor(), mode) + m_inserter(context.editor(), mode), + m_complete_timer{Clock::time_point::max(), + [this, &context](Timer& timer) { + m_completer.reset(context); + m_completer.select(context, 0); + }} { context.last_insert().first = mode; context.last_insert().second.clear(); @@ -554,7 +560,7 @@ public: { m_completer.reset(context); reset_completer = false; - m_completer.select(context, 0); + m_complete_timer.set_next_date(Clock::now() + std::chrono::milliseconds{250}); } } else if (key == Key{ Key::Modifiers::Control, 'r' }) @@ -580,6 +586,7 @@ public: private: bool m_insert_reg = false; IncrementalInserter m_inserter; + Timer m_complete_timer; WordCompleter m_completer; }; |
