mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(picker.actions): allow selecting the visual selection with <Tab>
This commit is contained in:
parent
18de5bb238
commit
96c76c6d9d
2 changed files with 15 additions and 2 deletions
|
@ -238,8 +238,8 @@ local defaults = {
|
|||
["j"] = "list_down",
|
||||
["k"] = "list_up",
|
||||
["q"] = "close",
|
||||
["<Tab>"] = "select_and_next",
|
||||
["<S-Tab>"] = "select_and_prev",
|
||||
["<Tab>"] = { "select_and_next", mode = { "n", "x" } },
|
||||
["<S-Tab>"] = { "select_and_prev", mode = { "n", "x" } },
|
||||
["<Down>"] = "list_down",
|
||||
["<Up>"] = "list_up",
|
||||
["<a-d>"] = "inspect",
|
||||
|
|
|
@ -296,6 +296,19 @@ end
|
|||
-- Toggle selection of current item
|
||||
---@param item? snacks.picker.Item
|
||||
function M:select(item)
|
||||
if item == nil and vim.fn.mode():find("^[vV]") and vim.api.nvim_get_current_buf() == self.win.buf then
|
||||
-- stop visual mode
|
||||
vim.cmd("normal! " .. vim.fn.mode():sub(1, 1))
|
||||
local from = vim.api.nvim_buf_get_mark(0, "<")
|
||||
local to = vim.api.nvim_buf_get_mark(0, ">")
|
||||
for i = math.min(from[1], to[1]), math.max(from[1], to[1]) do
|
||||
local it = self:get(self:row2idx(i))
|
||||
if it then
|
||||
self:select(it)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
item = item or self:current()
|
||||
if not item then
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue