Skip to content

Commit 2883260

Browse files
authored
Correctly identify tempfiles once symlinks are resolved (#3726)
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.
1 parent 090d31b commit 2883260

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

autoload/ale/path.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,16 @@ function! ale#path#IsAbsolute(filename) abort
124124
endfunction
125125

126126
let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h:h'))
127+
let s:resolved_temp_dir = resolve(s:temp_dir)
127128

128129
" Given a filename, return 1 if the file represents some temporary file
129-
" created by Vim.
130+
" created by Vim. If the temporary location is symlinked (e.g. macOS), some
131+
" linters may report the resolved version of the path, so both are checked.
130132
function! ale#path#IsTempName(filename) abort
131-
return ale#path#Simplify(a:filename)[:len(s:temp_dir) - 1] is# s:temp_dir
133+
let l:filename = ale#path#Simplify(a:filename)
134+
135+
return l:filename[:len(s:temp_dir) - 1] is# s:temp_dir
136+
\|| l:filename[:len(s:resolved_temp_dir) - 1] is# s:resolved_temp_dir
132137
endfunction
133138

134139
" Given a base directory, which must not have a trailing slash, and a

0 commit comments

Comments
 (0)