From cab1de00bd3a0d0a348d3c6acc10849cc73e35b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Fu=C3=9Fenegger?= Date: Tue, 20 Feb 2024 19:59:46 +0100 Subject: [PATCH] Normalize paths in from_pattern before comparing them (#539) Fix consistency issues on Windows when some linters use a single backslash, some use a double (escaped) backslash, and some still use a forward slash. This fix is confirmed to fix issues with Mypy on Windows, and it probably affects other linters as well. Fixes #480. Co-authored-by: Joshua T --- lua/lint/parser.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/lint/parser.lua b/lua/lint/parser.lua index 19ec9e35..a918fc64 100644 --- a/lua/lint/parser.lua +++ b/lua/lint/parser.lua @@ -39,6 +39,10 @@ function M.from_errorformat(efm, skeleton) end end +local normalize = (vim.fs ~= nil and vim.fs.normalize ~= nil) + and vim.fs.normalize + or function(path) return path end + --- Parse a linter's output using a Lua pattern --- @@ -69,7 +73,7 @@ function M.from_pattern(pattern, groups, severity_map, defaults, opts) else path = vim.fn.simplify(linter_cwd .. '/' .. captures.file) end - if path ~= buffer_path then + if normalize(path) ~= normalize(buffer_path) then return nil end end