From e9e4bcdd18f3cead736db0ad07b5bfcaaa3c851e Mon Sep 17 00:00:00 2001 From: Alexander Courtis Date: Fri, 25 Oct 2024 15:26:07 +1100 Subject: [PATCH] chore: resolve undefined-field --- lua/nvim-tree/diagnostics.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 05845ba2..a5cc5413 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -3,6 +3,8 @@ local utils = require("nvim-tree.utils") local view = require("nvim-tree.view") local log = require("nvim-tree.log") +local DirectoryNode = require("nvim-tree.node.directory") + local M = {} ---COC severity level strings to LSP severity levels @@ -125,7 +127,7 @@ end local function from_cache(node) local nodepath = uniformize_path(node.absolute_path) local max_severity = nil - if not node.nodes then + if not node:is(DirectoryNode) then -- direct cache hit for files max_severity = NODE_SEVERITIES[nodepath] else @@ -184,7 +186,7 @@ function M.get_diag_status(node) end -- dir but we shouldn't show on dirs at all - if node.nodes ~= nil and not M.show_on_dirs then + if node:is(DirectoryNode) and not M.show_on_dirs then return nil end @@ -195,13 +197,15 @@ function M.get_diag_status(node) node.diag_status = from_cache(node) end + local dir = node:as(DirectoryNode) + -- file - if not node.nodes then + if not dir then return node.diag_status end -- dir is closed or we should show on open_dirs - if not node.open or M.show_on_open_dirs then + if not dir.open or M.show_on_open_dirs then return node.diag_status end return nil