From acfb3ef6e0f7160f4a0c89b83525d1374755b4af Mon Sep 17 00:00:00 2001 From: Artem Lytkin Date: Thu, 20 Aug 2026 09:15:41 +0300 Subject: [PATCH] plugin: linter: Use `filepath.Base()` to compare the linted file The plugin's own `basename()` only treated `\` as a separator on Windows, so a linter reporting `a/b/d.c` for a buffer opened as `a\b\d.c` produced no match and its messages were silently dropped. Windows accepts both separators and a linter is free to normalize the path it prints. `filepath` is already imported here and `filepath.Base()` handles both separators on Windows while treating `\` as a regular filename character everywhere else, so the hand-rolled helper can go away. Fixes #3963 --- runtime/plugins/linter/linter.lua | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/runtime/plugins/linter/linter.lua b/runtime/plugins/linter/linter.lua index 3256bad792..4abfd8c73d 100644 --- a/runtime/plugins/linter/linter.lua +++ b/runtime/plugins/linter/linter.lua @@ -189,7 +189,7 @@ function onExit(output, args) elseif col == nil then hascol = false end - if basename(buf.Path) == basename(file) then + if filepath.Base(buf.Path) == filepath.Base(file) then local bmsg = nil if hascol then local mstart = buffer.Loc(tonumber(col-1+coff), tonumber(line-1+loff)) @@ -212,12 +212,3 @@ function split(str, sep) end return result end - -function basename(file) - local sep = "/" - if runtime.GOOS == "windows" then - sep = "\\" - end - local name = string.gsub(file, "(.*" .. sep .. ")(.*)", "%2") - return name -end