Skip to content

Commit afa6f0a

Browse files
committed
(mini.jump) Update ; to not ask for target in Operator-pending mode.
1 parent f0b63e8 commit afa6f0a

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lua/mini/jump.lua

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,11 @@ H.make_expr_jump = function(backward, till)
354354
return function()
355355
if H.is_disabled() then return '' end
356356

357-
-- Always ask for `target` as this will be used only in operator-pending
358-
-- mode. Dot-repeat will be implemented via expression-mapping.
359-
local target = H.get_target()
357+
-- Ask for `target` for non-repeating jump as this will be used only in
358+
-- operator-pending mode. Dot-repeat is supported via expression-mapping.
359+
local is_repeat_jump = backward == nil or till == nil
360+
local target = is_repeat_jump and MiniJump.state.target or H.get_target()
361+
360362
-- Stop if user supplied invalid target
361363
if target == nil then return '<Esc>' end
362364
H.update_state(target, backward, till, vim.v.count1)

tests/test_jump.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ T['Repeat jump with ;']['works in Normal and Visual mode'] = new_set({
811811
end,
812812
})
813813

814-
T['Repeat jump with ;']['works in Operator-pending mode'] = function()
814+
T['Repeat jump with ;']['works after jump in Operator-pending mode'] = function()
815815
-- It doesn't repeat actual operation, just performs same jump
816816
set_lines({ '1e2e3e4e5e' })
817817
set_cursor(1, 0)
@@ -829,6 +829,16 @@ T['Repeat jump with ;']['works in Operator-pending mode'] = function()
829829
eq(get_cursor(), { 1, 3 })
830830
end
831831

832+
T['Repeat jump with ;']['works in Operator-pending mode'] = function()
833+
set_lines({ '1e2e3e4e5e' })
834+
set_cursor(1, 0)
835+
836+
-- Should repeat without asking for target
837+
type_keys('f', 'e', 'd', ';')
838+
eq(get_lines(), { '13e4e5e' })
839+
eq(get_cursor(), { 1, 1 })
840+
end
841+
832842
T['Repeat jump with ;']['works with different mapping'] = function()
833843
child.api.nvim_del_keymap('n', ';')
834844
reload_module({ mappings = { repeat_jump = 'g;' } })

0 commit comments

Comments
 (0)