Make temporary file detection work on just about all platforms
This commit is contained in:
@@ -375,7 +375,7 @@ function! ale#engine#FixLocList(buffer, linter_name, loclist) abort
|
||||
\}
|
||||
|
||||
if has_key(l:old_item, 'filename')
|
||||
\&& l:old_item.filename[:len(s:temp_dir) - 1] isnot# s:temp_dir
|
||||
\&& !ale#path#IsTempName(l:old_item.filename)
|
||||
" Use the filename given.
|
||||
" Temporary files are assumed to be for this buffer,
|
||||
" and the filename is not included then, because it looks bad
|
||||
|
||||
@@ -80,22 +80,12 @@ function! ale#path#IsAbsolute(filename) abort
|
||||
return a:filename[:0] is# '/' || a:filename[1:2] is# ':\'
|
||||
endfunction
|
||||
|
||||
let s:temp_dir = fnamemodify(tempname(), ':h')
|
||||
|
||||
" Given a filename, return 1 if the file represents some temporary file
|
||||
" created by Vim.
|
||||
function! ale#path#IsTempName(filename) abort
|
||||
let l:prefix_list = [
|
||||
\ $TMPDIR,
|
||||
\ resolve($TMPDIR),
|
||||
\ '/run/user',
|
||||
\]
|
||||
|
||||
for l:prefix in l:prefix_list
|
||||
if a:filename[:len(l:prefix) - 1] is# l:prefix
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 0
|
||||
return a:filename[:len(s:temp_dir) - 1] is# s:temp_dir
|
||||
endfunction
|
||||
|
||||
" Given a base directory, which must not have a trailing slash, and a
|
||||
|
||||
Reference in New Issue
Block a user