mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-05 11:18:26 +00:00
fix(dashboard): take hidden items into account when calculating padding. Fixes #194
This commit is contained in:
parent
0df7a08b01
commit
736ce447e8
1 changed files with 12 additions and 5 deletions
|
@ -497,18 +497,25 @@ function D:resolve(item, results, parent)
|
||||||
first_child = first_child + 1
|
first_child = first_child + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- correct first/last taking hidden items into account
|
||||||
|
local first, last = first_child, #results
|
||||||
|
for c = first_child, #results do
|
||||||
|
first = first or not results[c].hidden and c or nil
|
||||||
|
last = not results[c].hidden and c or last
|
||||||
|
end
|
||||||
|
|
||||||
if item.gap then -- add padding between child items
|
if item.gap then -- add padding between child items
|
||||||
for i = first_child, #results - 1 do
|
for i = first, last - 1 do
|
||||||
results[i].padding = item.gap
|
results[i].padding = item.gap
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if item.padding then -- add padding to the first and last child items
|
if item.padding then -- add padding to the first and last child items
|
||||||
local padding = self:padding(item)
|
local padding = self:padding(item)
|
||||||
if padding[2] > 0 and results[first_child] then
|
if padding[2] > 0 and results[first] then
|
||||||
results[first_child].padding = { 0, padding[2] }
|
results[first].padding = { 0, padding[2] }
|
||||||
end
|
end
|
||||||
if padding[1] > 0 and results[#results] then
|
if padding[1] > 0 and results[last] then
|
||||||
results[#results].padding = { padding[1], 0 }
|
results[last].padding = { padding[1], 0 }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif type(item) ~= "table" then
|
elseif type(item) ~= "table" then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue