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
This commit is contained in:
Richard Li 2022-12-23 14:36:23 +13:00 committed by GitHub
parent e14c2895b4
commit 3000797e53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -108,13 +108,18 @@ 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, nodepath) and (not node.open or M.show_on_open_dirs) then
if
M.show_on_dirs
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)
node.diag_status = severity
add_sign(line, severity)