summaryrefslogtreecommitdiff
path: root/src/insert_completer.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-07-22 17:43:37 +1000
committerMaxime Coste <mawww@kakoune.org>2024-07-22 20:22:14 +1000
commite938d724f16ef06cbc97a4fedc20d56edf34e7f2 (patch)
treebc5828353bdc26259b59bf6eadf8e7bb08b9f062 /src/insert_completer.cc
parent6f562aa0add09092d390f7ea2691959490234ed0 (diff)
Handle word completion when recording macros
Make last insert and macro recording closer together, paving the way towards moving last insert to a register. Use a FunctionRef for insert completer key insertion support.
Diffstat (limited to 'src/insert_completer.cc')
-rw-r--r--src/insert_completer.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc
index 3e1bcd2d..73c08a43 100644
--- a/src/insert_completer.cc
+++ b/src/insert_completer.cc
@@ -416,7 +416,7 @@ InsertCompleter::~InsertCompleter()
m_options.unregister_watcher(*this);
}
-void InsertCompleter::select(int index, bool relative, Vector<Key>* keystrokes)
+void InsertCompleter::select(int index, bool relative, FunctionRef<void (Key)> record_key)
{
m_enabled = true;
if (not setup_ifn())
@@ -453,14 +453,13 @@ void InsertCompleter::select(int index, bool relative, Vector<Key>* keystrokes)
m_context.client().menu_select(m_current_candidate);
}
- if (keystrokes)
{
for (auto i = 0_byte; i < prefix_len; ++i)
- keystrokes->emplace_back(Key::Backspace);
+ record_key(Key::Backspace);
for (auto i = 0_byte; i < suffix_len; ++i)
- keystrokes->emplace_back(Key::Delete);
+ record_key(Key::Delete);
for (auto& c : candidate.completion)
- keystrokes->emplace_back(c);
+ record_key(c);
}
if (not candidate.on_select.empty())