Skip to content

Commit 3218d96

Browse files
committed
chore: resolve undefined-field
1 parent 568d0f1 commit 3218d96

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lua/nvim-tree/git/init.lua

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -338,17 +338,19 @@ function M.refresh_dir(dir)
338338
end)
339339
end
340340

341-
---@param n DirectoryNode
341+
---@param dir DirectoryNode?
342342
---@param projects table
343-
function M.reload_node_status(n, projects)
344-
local toplevel = M.get_toplevel(n.absolute_path)
343+
function M.reload_node_status(dir, projects)
344+
dir = dir and dir:as(DirectoryNode)
345+
if not dir or #dir.nodes == 0 then
346+
return
347+
end
348+
349+
local toplevel = M.get_toplevel(dir.absolute_path)
345350
local status = projects[toplevel] or {}
346-
for _, node in ipairs(n.nodes) do
347-
node:update_git_status(n:is_git_ignored(), status)
348-
local dir = node:as(DirectoryNode)
349-
if dir and #dir.nodes > 0 then
350-
dir:reload_node_status(projects)
351-
end
351+
for _, node in ipairs(dir.nodes) do
352+
node:update_git_status(dir:is_git_ignored(), status)
353+
M.reload_node_status(node:as(DirectoryNode), projects)
352354
end
353355
end
354356

0 commit comments

Comments
 (0)