Skip to content

Commit

Permalink
feat(layout): added some debugging tools
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 2, 2023
1 parent 07a1b6d commit f7bfbb4
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions lua/edgy/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,36 @@ function M.needs_layout()
for _, pos in ipairs({ "left", "right", "bottom", "top" }) do
local sidebar = Config.layout[pos]
if sidebar and #sidebar.wins > 0 then
local wins = vim.tbl_map(function(w)
local needed = vim.tbl_map(function(w)
return w.win
end, sidebar.wins)

local found = vim.tbl_filter(function(w)
return not vim.tbl_contains(done, w)
end, M.get(pos))

vim.list_extend(done, wins)
if not vim.deep_equal(wins, found) then
vim.list_extend(done, needed)
if not vim.deep_equal(needed, found) then
-- dd(pos, { needed = M.debug(needed), found = M.debug(found) })
return true
end
end
end
return false
end

---@param wins window[]
function M.debug(wins)
return vim.tbl_map(function(w)
local buf = vim.api.nvim_win_get_buf(w)
local name = vim.bo[buf].filetype
if name == "" then
name = vim.api.nvim_buf_get_name(buf)
end
return w .. " " .. name
end, wins)
end

---@param pos Edgy.Pos[]
---@param fn fun(sidebar: Edgy.Sidebar, pos: Edgy.Pos)
function M.foreach(pos, fn)
Expand Down

0 comments on commit f7bfbb4

Please sign in to comment.