From 2883260ade25f2b173a68ad185c314b1e3b72a61 Mon Sep 17 00:00:00 2001 From: Josh Pencheon Date: Wed, 2 Apr 2025 13:48:32 +0100 Subject: [PATCH] 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. --- autoload/ale/path.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autoload/ale/path.vim b/autoload/ale/path.vim index cc5c6658..a4260d39 100644 --- a/autoload/ale/path.vim +++ b/autoload/ale/path.vim @@ -124,11 +124,16 @@ function! ale#path#IsAbsolute(filename) abort endfunction 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 -" 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 - 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 " Given a base directory, which must not have a trailing slash, and a