Skip to content

Commit 8dda8d0

Browse files
committed
chore: resolve undefined-field
1 parent ce67acf commit 8dda8d0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lua/nvim-tree/diagnostics.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ local utils = require("nvim-tree.utils")
33
local view = require("nvim-tree.view")
44
local log = require("nvim-tree.log")
55

6+
local DirectoryNode = require("nvim-tree.node.directory")
7+
68
local M = {}
79

810
---COC severity level strings to LSP severity levels
@@ -125,7 +127,7 @@ end
125127
local function from_cache(node)
126128
local nodepath = uniformize_path(node.absolute_path)
127129
local max_severity = nil
128-
if not node.nodes then
130+
if not node:is(DirectoryNode) then
129131
-- direct cache hit for files
130132
max_severity = NODE_SEVERITIES[nodepath]
131133
else
@@ -184,7 +186,7 @@ function M.get_diag_status(node)
184186
end
185187

186188
-- dir but we shouldn't show on dirs at all
187-
if node.nodes ~= nil and not M.show_on_dirs then
189+
if node:is(DirectoryNode) and not M.show_on_dirs then
188190
return nil
189191
end
190192

@@ -195,13 +197,15 @@ function M.get_diag_status(node)
195197
node.diag_status = from_cache(node)
196198
end
197199

200+
local dir = node:as(DirectoryNode)
201+
198202
-- file
199-
if not node.nodes then
203+
if not dir then
200204
return node.diag_status
201205
end
202206

203207
-- dir is closed or we should show on open_dirs
204-
if not node.open or M.show_on_open_dirs then
208+
if not dir.open or M.show_on_open_dirs then
205209
return node.diag_status
206210
end
207211
return nil

0 commit comments

Comments
 (0)