Correctly identify tempfiles once symlinks are resolved (#3726)
Some checks failed
CI / build_image (push) Has been cancelled
CI / test_ale (--linters-only) (push) Has been cancelled
CI / test_ale (--lua-only) (push) Has been cancelled
CI / test_ale (--neovim-07-only) (push) Has been cancelled
CI / test_ale (--neovim-08-only) (push) Has been cancelled
CI / test_ale (--vim-80-only) (push) Has been cancelled
CI / test_ale (--vim-90-only) (push) Has been cancelled

Some linters will expand the paths of symlinked tempfiles when
reporting them back to ALE. This ensures that if they do, the filename
is still flagged appropriately as being temporary.
This commit is contained in:
Josh Pencheon
2025-04-02 13:48:32 +01:00
committed by GitHub
parent 090d31b79a
commit 2883260ade

View File

@@ -124,11 +124,16 @@ function! ale#path#IsAbsolute(filename) abort
endfunction endfunction
let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h')) let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h'))
let s:resolved_temp_dir = resolve(s:temp_dir)
" Given a filename, return 1 if the file represents some temporary file " Given a filename, return 1 if the file represents some temporary file
" created by Vim. " created by Vim. If the temporary location is symlinked (e.g. macOS), some
" linters may report the resolved version of the path, so both are checked.
function! ale#path#IsTempName(filename) abort function! ale#path#IsTempName(filename) abort
return ale#path#Simplify(a:filename)[:len(s:temp_dir) - 1] is# s:temp_dir let l:filename = ale#path#Simplify(a:filename)
return l:filename[:len(s:temp_dir) - 1] is# s:temp_dir
\|| l:filename[:len(s:resolved_temp_dir) - 1] is# s:resolved_temp_dir
endfunction endfunction
" Given a base directory, which must not have a trailing slash, and a " Given a base directory, which must not have a trailing slash, and a