From c79bbaa3de662499d3579e0da160ea8f305d19f2 Mon Sep 17 00:00:00 2001 From: chomosuke Date: Sat, 17 Dec 2022 18:28:44 +1300 Subject: [PATCH 1/2] fix diagnostics showing up on file/dir with same prefix --- lua/nvim-tree/diagnostics.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index 3771779def3..d075b7bfcd4 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -114,7 +114,11 @@ function M.update() for line, node in pairs(nodes_by_line) do local nodepath = utils.canonical_path(node.absolute_path) log.line("diagnostics", " %d checking nodepath '%s'", line, nodepath) - if M.show_on_dirs and vim.startswith(bufpath, nodepath) and (not node.open or M.show_on_open_dirs) then + if + M.show_on_dirs + and vim.startswith(bufpath:gsub("\\", "/"), nodepath:gsub("\\", "/") .. "/") + and (not node.open or M.show_on_open_dirs) + then log.line("diagnostics", " matched fold node '%s'", node.absolute_path) node.diag_status = severity add_sign(line, severity) From a76ff1e1f02889d07c519508c927dd34f42a70a5 Mon Sep 17 00:00:00 2001 From: chomosuke Date: Mon, 19 Dec 2022 19:52:08 +1300 Subject: [PATCH 2/2] using fnamemodify instead of gsub --- lua/nvim-tree/diagnostics.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/nvim-tree/diagnostics.lua b/lua/nvim-tree/diagnostics.lua index d075b7bfcd4..09c2b12df92 100644 --- a/lua/nvim-tree/diagnostics.lua +++ b/lua/nvim-tree/diagnostics.lua @@ -108,15 +108,16 @@ function M.update() end for bufname, severity in pairs(buffer_severity) do - local bufpath = utils.canonical_path(bufname) + local bufpath = vim.fn.fnamemodify(utils.canonical_path(bufname), ":p") log.line("diagnostics", " bufpath '%s' severity %d", bufpath, severity) if 0 < severity and severity < 5 then for line, node in pairs(nodes_by_line) do - local nodepath = utils.canonical_path(node.absolute_path) + local nodepath = vim.fn.fnamemodify(utils.canonical_path(node.absolute_path), ":p") log.line("diagnostics", " %d checking nodepath '%s'", line, nodepath) if M.show_on_dirs - and vim.startswith(bufpath:gsub("\\", "/"), nodepath:gsub("\\", "/") .. "/") + and node.nodes + and vim.startswith(bufpath, nodepath) and (not node.open or M.show_on_open_dirs) then log.line("diagnostics", " matched fold node '%s'", node.absolute_path)