Skip to content

Commit fce6020

Browse files
Illia Shkrobakiyoon
authored andcommitted
fix(repeatable_move): repeat_last_move always uses count 1 when used in operator-pending (no) mode.
1 parent 52bda74 commit fce6020

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lua/nvim-treesitter-textobjects/repeatable_move.lua

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ M.repeat_last_move = function(opts_extend)
4343
return
4444
end
4545
local opts = vim.tbl_deep_extend('force', M.last_move.opts, opts_extend or {})
46+
-- The call to `normal` in `force_operator_pending_visual_mode` resets `vim.v.count1` to 1 while in
47+
-- operator-pending (no) mode. Meaning, that the `vim.v.count1` must be saved before the
48+
-- `force_operator_pending_visual_mode` call and used later on instead of new `vim.v.count1`.
49+
local count1 = vim.v.count1
4650
if M.last_move.func == 'f' or M.last_move.func == 't' then
4751
force_operator_pending_visual_mode()
48-
vim.cmd([[normal! ]] .. vim.v.count1 .. (opts.forward and ';' or ','))
52+
vim.cmd([[normal! ]] .. count1 .. (opts.forward and ';' or ','))
4953
elseif M.last_move.func == 'F' or M.last_move.func == 'T' then
5054
force_operator_pending_visual_mode()
51-
vim.cmd([[normal! ]] .. vim.v.count1 .. (opts.forward and ',' or ';'))
55+
vim.cmd([[normal! ]] .. count1 .. (opts.forward and ',' or ';'))
5256
else
5357
-- we assume other textobjects (move) already handle operator-pending mode correctly
5458
M.last_move.func(opts, unpack(M.last_move.additional_args))

0 commit comments

Comments
 (0)