summaryrefslogtreecommitdiff
path: root/src/insert_completer.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-03-23 16:25:32 +1100
committerMaxime Coste <mawww@kakoune.org>2024-03-23 16:29:03 +1100
commit6e4bb5fbc5bc01c9143e40e3f4cb5b48efb020ec (patch)
tree2b8a3776b508d0f43daae0e1aad2de58291372c7 /src/insert_completer.cc
parent71b003b6841f2b5a04f12a5677db729b3d24ce44 (diff)
Refactor last insert recording logic
Only record non-synthetized insertions, removing the need to re-record on replay and fixing the last replay getting dropped by macro execution. Fixes #5122
Diffstat (limited to 'src/insert_completer.cc')
-rw-r--r--src/insert_completer.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc
index af387506..c50fbe00 100644
--- a/src/insert_completer.cc
+++ b/src/insert_completer.cc
@@ -413,7 +413,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, Vector<Key>* keystrokes)
{
m_enabled = true;
if (not setup_ifn())
@@ -450,12 +450,15 @@ void InsertCompleter::select(int index, bool relative, Vector<Key>& keystrokes)
m_context.client().menu_select(m_current_candidate);
}
- for (auto i = 0_byte; i < prefix_len; ++i)
- keystrokes.emplace_back(Key::Backspace);
- for (auto i = 0_byte; i < suffix_len; ++i)
- keystrokes.emplace_back(Key::Delete);
- for (auto& c : candidate.completion)
- keystrokes.emplace_back(c);
+ if (keystrokes)
+ {
+ for (auto i = 0_byte; i < prefix_len; ++i)
+ keystrokes->emplace_back(Key::Backspace);
+ for (auto i = 0_byte; i < suffix_len; ++i)
+ keystrokes->emplace_back(Key::Delete);
+ for (auto& c : candidate.completion)
+ keystrokes->emplace_back(c);
+ }
if (not candidate.on_select.empty())
CommandManager::instance().execute(candidate.on_select, m_context);