diff --git a/lua/snacks/layout.lua b/lua/snacks/layout.lua index 8bc3a38c..3437e04e 100644 --- a/lua/snacks/layout.lua +++ b/lua/snacks/layout.lua @@ -324,8 +324,14 @@ function M:update_box(box, parent) end local free = vim.deepcopy(dim) + local box_win = self.box_wins[box.id] + local function size(child) - return child[size_main] or 0 + local ret = child[size_main] or 0 + if type(ret) == "function" then + ret = ret(box_win) + end + return ret end local dims = {} ---@type table @@ -371,7 +377,6 @@ function M:update_box(box, parent) end -- update box win - local box_win = self.box_wins[box.id] if box_win then if not is_root then box_win.opts.win = self.root.win