mirror of
https://github.com/folke/snacks.nvim
synced 2025-12-23 08:47:57 +00:00
fix(picker): close picker when layout closes. Closes #2365
This commit is contained in:
parent
143e9b58c7
commit
779746f9a8
2 changed files with 8 additions and 0 deletions
|
|
@ -33,6 +33,7 @@ M.meta = {
|
|||
---@field hidden? string[] list of windows that will be excluded from the layout (but can be toggled)
|
||||
---@field on_update? fun(layout: snacks.layout)
|
||||
---@field on_update_pre? fun(layout: snacks.layout)
|
||||
---@field on_close? fun(layout: snacks.layout)
|
||||
local defaults = {
|
||||
layout = {
|
||||
width = 0.6,
|
||||
|
|
@ -523,6 +524,9 @@ function M:close(opts)
|
|||
win:destroy()
|
||||
end
|
||||
vim.schedule(function()
|
||||
if self.opts.on_close then
|
||||
self.opts.on_close(self)
|
||||
end
|
||||
self.opts = nil
|
||||
self.root = nil
|
||||
self.wins = nil
|
||||
|
|
|
|||
|
|
@ -245,6 +245,9 @@ function M:init_layout(layout)
|
|||
preview = self.preview.win,
|
||||
},
|
||||
hidden = layout.hidden,
|
||||
on_close = function()
|
||||
self:close()
|
||||
end,
|
||||
on_update = function()
|
||||
self.preview:refresh(self)
|
||||
self.input:update()
|
||||
|
|
@ -365,6 +368,7 @@ function M:set_layout(layout)
|
|||
)
|
||||
end
|
||||
self.list.reverse = layout.reverse
|
||||
self.layout.opts.on_close = nil -- prevent closing the picker when changing layout
|
||||
self.layout:close({ wins = false })
|
||||
self:init_layout(layout)
|
||||
self.layout:show()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue