Skip to content

Commit 0e9b844

Browse files
committed
chore: resolve undefined-field
1 parent e38c387 commit 0e9b844

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lua/nvim-tree/renderer/builder.lua

+8-4
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function Builder:unwrap_highlighted_strings(highlighted_strings)
142142
end
143143

144144
---@private
145-
---@param node Node
145+
---@param node DirectoryNode
146146
---@return HighlightedString icon
147147
---@return HighlightedString name
148148
function Builder:build_folder(node)
@@ -352,15 +352,19 @@ end
352352
---@param idx integer line number starting at 1
353353
---@param num_children integer of node
354354
function Builder:build_line(node, idx, num_children)
355+
local dir = node:as(DirectoryNode)
356+
local dir_link = node:as(FileLinkNode)
357+
local file_link = node:as(DirectoryLinkNode)
358+
355359
-- various components
356360
local indent_markers = pad.get_indent_markers(self.depth, idx, num_children, node, self.markers)
357361
local arrows = pad.get_arrows(node)
358362

359363
-- main components
360364
local icon, name
361-
if node:is(DirectoryNode) then
362-
icon, name = self:build_folder(node)
363-
elseif node:is(DirectoryLinkNode) or node:is(FileLinkNode) then
365+
if dir then
366+
icon, name = self:build_folder(dir)
367+
elseif dir_link or file_link then
364368
icon, name = self:build_symlink(node)
365369
else
366370
icon, name = self:build_file(node)

0 commit comments

Comments
 (0)