mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
feat(picker): opening a picker with the same source as an active picker, will close it instead (toggle)
This commit is contained in:
parent
92710dfb0b
commit
b6cf033051
1 changed files with 7 additions and 0 deletions
|
@ -17,6 +17,9 @@ local M = setmetatable({}, {
|
|||
end,
|
||||
---@param M snacks.picker
|
||||
__index = function(M, k)
|
||||
if k == "current" then
|
||||
return nil
|
||||
end
|
||||
if type(k) ~= "string" then
|
||||
return
|
||||
end
|
||||
|
@ -69,6 +72,10 @@ function M.pick(source, opts)
|
|||
opts.source = "pickers"
|
||||
return M.pick(opts)
|
||||
end
|
||||
if opts.source and M.current and M.current.opts.source == opts.source then
|
||||
M.current:close()
|
||||
return
|
||||
end
|
||||
return require("snacks.picker.core.picker").new(opts)
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue