Skip to content

Commit 3000797

Browse files
authored
fix(diagnostics): do not show on file/dir with same prefix (#1832)
* fix diagnostics showing up on file/dir with same prefix * using fnamemodify instead of gsub
1 parent e14c289 commit 3000797

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lua/nvim-tree/diagnostics.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,18 @@ function M.update()
108108
end
109109

110110
for bufname, severity in pairs(buffer_severity) do
111-
local bufpath = utils.canonical_path(bufname)
111+
local bufpath = vim.fn.fnamemodify(utils.canonical_path(bufname), ":p")
112112
log.line("diagnostics", " bufpath '%s' severity %d", bufpath, severity)
113113
if 0 < severity and severity < 5 then
114114
for line, node in pairs(nodes_by_line) do
115-
local nodepath = utils.canonical_path(node.absolute_path)
115+
local nodepath = vim.fn.fnamemodify(utils.canonical_path(node.absolute_path), ":p")
116116
log.line("diagnostics", " %d checking nodepath '%s'", line, nodepath)
117-
if M.show_on_dirs and vim.startswith(bufpath, nodepath) and (not node.open or M.show_on_open_dirs) then
117+
if
118+
M.show_on_dirs
119+
and node.nodes
120+
and vim.startswith(bufpath, nodepath)
121+
and (not node.open or M.show_on_open_dirs)
122+
then
118123
log.line("diagnostics", " matched fold node '%s'", node.absolute_path)
119124
node.diag_status = severity
120125
add_sign(line, severity)

0 commit comments

Comments
 (0)