feat(nvim-tree): aggregate child git status onto directory nodes
This commit is contained in:
@@ -45,6 +45,29 @@ function Status:by_kind(kind)
|
||||
return out
|
||||
end
|
||||
|
||||
---@param prefix string
|
||||
---@return ow.Git.Status.Entry[]
|
||||
function Status:aggregate_at(prefix)
|
||||
local match = (prefix == "" or prefix == ".") and "" or prefix .. "/"
|
||||
local seen = {}
|
||||
local out = {}
|
||||
for path, list in pairs(self.entries) do
|
||||
if path == prefix or vim.startswith(path, match) then
|
||||
for _, e in ipairs(list) do
|
||||
local key = e.char .. "\0" .. e.hl
|
||||
if not seen[key] then
|
||||
seen[key] = true
|
||||
table.insert(out, e)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(out, function(a, b)
|
||||
return a.char < b.char
|
||||
end)
|
||||
return out
|
||||
end
|
||||
|
||||
---@param x string
|
||||
---@return string char, string hl
|
||||
local function staged_attrs(x)
|
||||
|
||||
Reference in New Issue
Block a user