Add defensive ale#Set for c_build_dir_names in FindCompileCommands

Mirror the existing s:CanParseMakefile pattern to ensure the
g:ale_c_build_dir_names variable always exists when ale#Var is
called, even if test Save/Restore cycles delete it.

Co-authored-by: w0rp <3518142+w0rp@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-02-17 20:28:19 +00:00
parent 014c959fee
commit c849345a8d

View File

@@ -246,6 +246,15 @@ function! ale#c#FindCompileCommands(buffer) abort
return [fnamemodify(l:json_file, ':h'), l:json_file]
endif
" Something somewhere seems to delete this setting in tests, so ensure
" we always have a default value.
call ale#Set('c_build_dir_names', [
\ 'build',
\ 'build/Debug',
\ 'build/Release',
\ 'bin',
\])
" Search in build directories if we can't find it in the project.
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
for l:dirname in ale#Var(a:buffer, 'c_build_dir_names')