mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(picker.actions): vim.v.count1 should be 1 in insert mode. Closes #2492
This commit is contained in:
parent
dec29f5566
commit
d902c0a415
1 changed files with 10 additions and 4 deletions
|
|
@ -26,6 +26,12 @@ local edit_cmd = {
|
|||
tabdrop = "tab drop",
|
||||
}
|
||||
|
||||
--- Get `vim.v.count1`, but return 1 if in insert mode.
|
||||
--- In insert mode, you can't really pass a count, so we default to 1
|
||||
local function count1()
|
||||
return vim.fn.mode():sub(1, 1) == "i" and 1 or vim.v.count1
|
||||
end
|
||||
|
||||
function M.jump(picker, _, action)
|
||||
---@cast action snacks.picker.jump.Action
|
||||
-- if we're still in insert mode, stop it and schedule
|
||||
|
|
@ -614,14 +620,14 @@ end
|
|||
--- and moves the cursor to the next item.
|
||||
function M.select_and_next(picker)
|
||||
picker.list:select()
|
||||
picker.list:_move(vim.v.count1)
|
||||
picker.list:_move(count1())
|
||||
end
|
||||
|
||||
--- Toggles the selection of the current item,
|
||||
--- and moves the cursor to the prev item.
|
||||
function M.select_and_prev(picker)
|
||||
picker.list:select()
|
||||
picker.list:_move(-vim.v.count1)
|
||||
picker.list:_move(-count1())
|
||||
end
|
||||
|
||||
--- Selects all items in the list.
|
||||
|
|
@ -805,11 +811,11 @@ function M.list_bottom(picker)
|
|||
end
|
||||
|
||||
function M.list_down(picker)
|
||||
picker.list:move(vim.v.count1)
|
||||
picker.list:move(count1())
|
||||
end
|
||||
|
||||
function M.list_up(picker)
|
||||
picker.list:move(-vim.v.count1)
|
||||
picker.list:move(-count1())
|
||||
end
|
||||
|
||||
function M.list_scroll_top(picker)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue