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 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? fun(layout: snacks.layout)
|
||||||
---@field on_update_pre? fun(layout: snacks.layout)
|
---@field on_update_pre? fun(layout: snacks.layout)
|
||||||
|
---@field on_close? fun(layout: snacks.layout)
|
||||||
local defaults = {
|
local defaults = {
|
||||||
layout = {
|
layout = {
|
||||||
width = 0.6,
|
width = 0.6,
|
||||||
|
|
@ -523,6 +524,9 @@ function M:close(opts)
|
||||||
win:destroy()
|
win:destroy()
|
||||||
end
|
end
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
|
if self.opts.on_close then
|
||||||
|
self.opts.on_close(self)
|
||||||
|
end
|
||||||
self.opts = nil
|
self.opts = nil
|
||||||
self.root = nil
|
self.root = nil
|
||||||
self.wins = nil
|
self.wins = nil
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,9 @@ function M:init_layout(layout)
|
||||||
preview = self.preview.win,
|
preview = self.preview.win,
|
||||||
},
|
},
|
||||||
hidden = layout.hidden,
|
hidden = layout.hidden,
|
||||||
|
on_close = function()
|
||||||
|
self:close()
|
||||||
|
end,
|
||||||
on_update = function()
|
on_update = function()
|
||||||
self.preview:refresh(self)
|
self.preview:refresh(self)
|
||||||
self.input:update()
|
self.input:update()
|
||||||
|
|
@ -365,6 +368,7 @@ function M:set_layout(layout)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
self.list.reverse = layout.reverse
|
self.list.reverse = layout.reverse
|
||||||
|
self.layout.opts.on_close = nil -- prevent closing the picker when changing layout
|
||||||
self.layout:close({ wins = false })
|
self.layout:close({ wins = false })
|
||||||
self:init_layout(layout)
|
self:init_layout(layout)
|
||||||
self.layout:show()
|
self.layout:show()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue