Skip to content

Commit 79245ce

Browse files
committed
chore: resolve undefined-field
1 parent ecb22c7 commit 79245ce

File tree

1 file changed

+9
-5
lines changed
  • lua/nvim-tree/renderer/decorator

1 file changed

+9
-5
lines changed

lua/nvim-tree/renderer/decorator/git.lua

+9-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ local HL_POSITION = require("nvim-tree.enum").HL_POSITION
44
local ICON_PLACEMENT = require("nvim-tree.enum").ICON_PLACEMENT
55

66
local Decorator = require("nvim-tree.renderer.decorator")
7+
local DirectoryNode = require("nvim-tree.node.directory")
78

89
---@class HighlightedStringGit: HighlightedString
910
---@field ord number decreasing priority
1011

12+
---@alias IconsByStatus table<string, HighlightedStringGit[]> by human status
13+
---@alias IconsByXY table<string, HighlightedStringGit[]> by porcelain status
14+
1115
---@class (exact) DecoratorGit: Decorator
1216
---@field file_hl table<string, string>? by porcelain status e.g. "AM"
1317
---@field folder_hl table<string, string>? by porcelain status
14-
---@field icons_by_status HighlightedStringGit[]? by human status
15-
---@field icons_by_xy table<string, HighlightedStringGit[]>? by porcelain status
18+
---@field icons_by_status IconsByStatus?
19+
---@field icons_by_xy IconsByXY?
1620
local DecoratorGit = Decorator:new()
1721

1822
---Static factory method
@@ -49,7 +53,7 @@ function DecoratorGit:create(opts, explorer)
4953
return o
5054
end
5155

52-
---@param glyphs table<string, string> user glyps
56+
---@param glyphs IconsByStatus user glyps
5357
function DecoratorGit:build_icons_by_status(glyphs)
5458
self.icons_by_status = {
5559
staged = { str = glyphs.staged, hl = { "NvimTreeGitStagedIcon" }, ord = 1 },
@@ -62,7 +66,7 @@ function DecoratorGit:build_icons_by_status(glyphs)
6266
}
6367
end
6468

65-
---@param icons HighlightedStringGit[]
69+
---@param icons IconsByXY
6670
function DecoratorGit:build_icons_by_xy(icons)
6771
self.icons_by_xy = {
6872
["M "] = { icons.staged },
@@ -214,7 +218,7 @@ function DecoratorGit:calculate_highlight(node)
214218
return nil
215219
end
216220

217-
if node.nodes then
221+
if node:is(DirectoryNode) then
218222
return self.folder_hl[git_status[1]]
219223
else
220224
return self.file_hl[git_status[1]]

0 commit comments

Comments
 (0)