summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-07-19 13:03:26 +1000
committerMaxime Coste <mawww@kakoune.org>2024-07-19 13:03:26 +1000
commitc971c42002b0567a1dba1e05de88cbd70cfa5676 (patch)
tree8fa964cef1da42445b660c536bdfe9d27f947f3c /src/input_handler.cc
parent8a109bd2f45d5deaaee479f5f2de802d2727e97e (diff)
Record macros in repeat last insert
This fixes an issue with the following hooks: hook global InsertCompletionShow .* %{ map window insert <tab> <c-n> } hook global InsertCompletionHide .* %{ unmap window insert <tab> <c-n> } When repeating a last insert using <tab> to select a completion, it inserts a <tab> instead of selecting, then the insert completion tries to erase the inserted text with backspaces but fails to totally do that as it erases the tab character first.
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index eb809b5f..15156c2b 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -1307,7 +1307,7 @@ public:
}
else if (key == ctrl('n') or key == ctrl('p') or key.modifiers == Key::Modifiers::MenuSelect)
{
- if (m_last_insert and not synthesized)
+ if (m_last_insert)
m_last_insert->keys.pop_back();
bool relative = key.modifiers != Key::Modifiers::MenuSelect;
int index = relative ? (key == ctrl('n') ? 1 : -1) : key.key;
@@ -1656,20 +1656,22 @@ void InputHandler::handle_key(Key key)
++m_handle_key_level;
auto dec = on_scope_end([this]{ --m_handle_key_level;} );
- if (m_last_insert.recording and m_handle_key_level <= 1)
- m_last_insert.keys.push_back(key);
+ auto process_key = [&](Key k, bool synthesized) {
+ if (m_last_insert.recording and m_handle_key_level <= 1)
+ m_last_insert.keys.push_back(k);
+ current_mode().handle_key(k, synthesized);
+ };
const auto keymap_mode = current_mode().keymap_mode();
KeymapManager& keymaps = m_context.keymaps();
if (keymaps.is_mapped(key, keymap_mode) and not m_context.keymaps_disabled())
{
ScopedSetBool noninteractive{context().noninteractive()};
-
for (auto& k : keymaps.get_mapping_keys(key, keymap_mode))
- current_mode().handle_key(k, true);
+ process_key(k, true);
}
else
- current_mode().handle_key(key, m_handle_key_level > 1);
+ process_key(key, m_handle_key_level > 1);
// do not record the key that made us enter or leave recording mode,
// and the ones that are triggered recursively by previous keys.