1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-08-16 16:20:38 +03:00

Make insert repeat (.) more consistent

Insert repeat will now only record non-synthesized keys, and when played back
execute mappings as well. Constructing some tests, and with the specific goal
of fixing https://github.com/alexherbo2/auto-pairs.kak/issues/38, this appeared to
be the best approach. Other options could be evaluating the maps only when recording,
but this gave other issues (see tests/normal/repeat-insert/repeat-insert-mapped)

At this point, repeat-insert may be essentially just a hardcoded macro, at least I
haven't identified the difference. If this really is the case, it may make sense to
give it a dedicated register, and implement it as a macro.

Fixes #3600
This commit is contained in:
Tobias Pisani 2024-02-23 16:53:30 +01:00
parent 2d9c84e363
commit dbe8528231
12 changed files with 13 additions and 3 deletions

View File

@ -1582,7 +1582,7 @@ void InputHandler::repeat_last_insert()
// refill last_insert, this is very inefficient, but necessary at the moment
// to properly handle insert completion
m_last_insert.keys.push_back(key);
current_mode().handle_key(key, true);
handle_key(key);
}
kak_assert(dynamic_cast<InputModes::Normal*>(&current_mode()) != nullptr);
}
@ -1655,11 +1655,12 @@ void InputHandler::handle_key(Key key)
auto dec = on_scope_end([this]{ --m_handle_key_level;} );
auto process_key = [&](Key key, bool synthesized) {
if (m_last_insert.recording)
m_last_insert.keys.push_back(key);
current_mode().handle_key(key, synthesized);
};
if (m_last_insert.recording and m_handle_key_level <= 1)
m_last_insert.keys.push_back(key);
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())

View File

@ -0,0 +1 @@
:hook -group h g InsertChar f %{exec FINSERTED}<ret>ifoo<esc>.\.\ifoo<esc>.

View File

@ -0,0 +1 @@
fFINSERTEDoofFINSERTEDoofoofoofoo

View File

@ -0,0 +1 @@
ixyz<esc>.

View File

@ -0,0 +1 @@
zzxx

View File

@ -0,0 +1 @@
map global insert y '<a-;>gh'

View File

@ -0,0 +1 @@
i<a-;>:execute-keys foo<ret><esc>.

View File

@ -0,0 +1 @@
foofoo

View File

@ -0,0 +1 @@
ifoo<a-;>ghbar<esc>.

View File

@ -0,0 +1 @@
barbarfoofoo