fix(layout): close layout if one of the box windows closes

This commit is contained in:
Folke Lemaitre 2025-01-13 22:07:55 +01:00
parent 9b09feae51
commit 2de1a7c84f
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -76,18 +76,18 @@ function M.new(opts)
self.root = self.box_wins[1]
assert(self.root, "no root box found")
-- close layout when any win is closed
for w, win in pairs(self.wins) do
self.win_opts[w] = vim.deepcopy(win.opts)
end
-- close layout when any win is closed
self.root:on("WinClosed", function(_, ev)
if self.closed then
return true
end
local wid = tonumber(ev.match)
for w, win in pairs(self.wins) do
if self:is_enabled(w) and win.win == wid then
for _, win in pairs(self:get_wins()) do
if win.win == wid then
self:close()
return true
end
@ -266,7 +266,7 @@ function M:update_box(box, parent)
end
---@param widget? snacks.layout.Widget
---@private
---@package
function M:get_wins(widget)
local ret = {} ---@type snacks.win[]
self:each(function(w)