Skip to content

Commit 72b0194

Browse files
committed
fix(clue): tweak macro execution mappings for better integration
Details: - Using `feedkeys(<key>, 'nx')` makes some modules/plugins not work with macro execution. This seems to be because keys are handled as if coming from mapping, which might be not good. The solution is to use `t` flag to handle keys "as if type". Removing `x` flag is not necessary, but it seems to be not needed. Resolve nvim-mini/MiniMax#24
1 parent 6e885e4 commit 72b0194

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lua/mini/clue.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,9 @@ H.apply_config = function(config)
12251225
if register == nil then return end
12261226
MiniClue.disable_all_triggers()
12271227
vim.schedule(function() MiniClue.enable_all_triggers() end)
1228-
pcall(vim.api.nvim_feedkeys, vim.v.count1 .. key .. register, 'nx', false)
1228+
-- NOTE: Use `t` flag for "Handle as if typed" for better integration with
1229+
-- other modules/plugins (like 'mini.jump').
1230+
pcall(vim.api.nvim_feedkeys, vim.v.count1 .. key .. register, 'nt', false)
12291231
end
12301232

12311233
local macro_keymap_opts = { nowait = true, desc = "Execute macro without 'mini.clue' triggers" }

tests/test_clue.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3180,6 +3180,22 @@ T['Reproducing keys']['works with macros'] = function()
31803180
eq(child.fn.getreg('w'), ':enew\ri\18a\27')
31813181
end
31823182

3183+
T['Reproducing keys']["works with macros and 'mini.jump'"] = function()
3184+
if child.fn.has('nvim-0.10') == 0 then MiniTest.skip('The solution works only on Neovim>=0.10') end
3185+
child.lua("require('mini.jump').setup()")
3186+
load_module()
3187+
set_lines({ ' [aaa][bbb][ccc]' })
3188+
3189+
type_keys(small_time, 'qq', '0f', '[', 'r(f', ']', 'r)', 'q')
3190+
eq(get_lines(), { ' (aaa)[bbb][ccc]' })
3191+
3192+
type_keys('Q')
3193+
eq(get_lines(), { ' (aaa)(bbb)[ccc]' })
3194+
3195+
type_keys('@q')
3196+
eq(get_lines(), { ' (aaa)(bbb)(ccc)' })
3197+
end
3198+
31833199
T['Reproducing keys']['works when key query is executed in presence of longer keymaps'] = function()
31843200
mock_comment_operators()
31853201
load_module({ triggers = { { mode = 'n', keys = 'g' }, { mode = 'o', keys = 'i' } } })

0 commit comments

Comments
 (0)