From 6e4bb5fbc5bc01c9143e40e3f4cb5b48efb020ec Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sat, 23 Mar 2024 16:25:32 +1100 Subject: 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 --- src/insert_completer.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/insert_completer.cc') 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& keystrokes) +void InsertCompleter::select(int index, bool relative, Vector* keystrokes) { m_enabled = true; if (not setup_ifn()) @@ -450,12 +450,15 @@ void InsertCompleter::select(int index, bool relative, Vector& 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); -- cgit v1.2.3