mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
perf(picker): fixed some issues with closed pickers not always being garbage collected
This commit is contained in:
parent
b59f4ff477
commit
eebf44a34e
7 changed files with 82 additions and 24 deletions
|
@ -382,18 +382,23 @@ function M:close(opts)
|
|||
for w, win in pairs(self.wins) do
|
||||
if opts.wins == false then
|
||||
win.opts = self.win_opts[w]
|
||||
elseif win:valid() then
|
||||
win:close()
|
||||
else
|
||||
win:destroy()
|
||||
end
|
||||
end
|
||||
for _, win in pairs(self.box_wins) do
|
||||
win:close()
|
||||
win:destroy()
|
||||
end
|
||||
self.opts = nil
|
||||
self.root = nil
|
||||
self.wins = nil
|
||||
self.box_wins = nil
|
||||
self.win_opts = nil
|
||||
end
|
||||
|
||||
--- Check if layout is valid (visible)
|
||||
function M:valid()
|
||||
return self.root:valid()
|
||||
return not self.closed and self.root:valid()
|
||||
end
|
||||
|
||||
--- Check if the window has been used in the layout
|
||||
|
@ -402,6 +407,28 @@ function M:is_enabled(w)
|
|||
return not self:is_hidden(w) and self.wins[w].enabled
|
||||
end
|
||||
|
||||
function M:hide()
|
||||
for _, win in ipairs(self:get_wins()) do
|
||||
if win:valid() then
|
||||
vim.api.nvim_win_set_config(win.win, { hide = true })
|
||||
if win.backdrop and win.backdrop:valid() then
|
||||
vim.api.nvim_win_set_config(win.backdrop.win, { hide = true })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M:unhide()
|
||||
for _, win in ipairs(self:get_wins()) do
|
||||
if win:valid() then
|
||||
vim.api.nvim_win_set_config(win.win, { hide = false })
|
||||
if win.backdrop and win.backdrop:valid() then
|
||||
vim.api.nvim_win_set_config(win.backdrop.win, { hide = false })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Show the layout
|
||||
function M:show()
|
||||
if self:valid() then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue