mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-17 17:55:56 +08:00
Fix #2195 - Handle the command key being missing
This commit is contained in:
@@ -221,7 +221,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
|||||||
let l:file_list = get(a:file_lookup, l:basename, [])
|
let l:file_list = get(a:file_lookup, l:basename, [])
|
||||||
|
|
||||||
for l:item in l:file_list
|
for l:item in l:file_list
|
||||||
if bufnr(l:item.file) is a:buffer
|
if bufnr(l:item.file) is a:buffer && has_key(l:item, 'command')
|
||||||
return ale#c#ParseCFlags(l:item.directory, l:item.command)
|
return ale#c#ParseCFlags(l:item.directory, l:item.command)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@@ -234,6 +234,7 @@ function! ale#c#ParseCompileCommandsFlags(buffer, file_lookup, dir_lookup) abort
|
|||||||
|
|
||||||
for l:item in l:dir_list
|
for l:item in l:dir_list
|
||||||
if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir
|
if ale#path#Simplify(fnamemodify(l:item.file, ':h')) is? l:dir
|
||||||
|
\&& has_key(l:item, 'command')
|
||||||
return ale#c#ParseCFlags(l:item.directory, l:item.command)
|
return ale#c#ParseCFlags(l:item.directory, l:item.command)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
|||||||
@@ -167,6 +167,18 @@ Execute(ParseCompileCommandsFlags should parse some basic flags):
|
|||||||
\ },
|
\ },
|
||||||
\ ] }, {})
|
\ ] }, {})
|
||||||
|
|
||||||
|
Execute(ParseCompileCommandsFlags should tolerate items without commands):
|
||||||
|
noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c'))
|
||||||
|
|
||||||
|
AssertEqual
|
||||||
|
\ '',
|
||||||
|
\ ale#c#ParseCompileCommandsFlags(bufnr(''), { "xmms2-mpris.c": [
|
||||||
|
\ {
|
||||||
|
\ 'directory': '/foo/bar/xmms2-mpris',
|
||||||
|
\ 'file': '/foo/bar/xmms2-mpris/src/xmms2-mpris.c',
|
||||||
|
\ },
|
||||||
|
\ ] }, {})
|
||||||
|
|
||||||
Execute(ParseCompileCommandsFlags should fall back to files in the same directory):
|
Execute(ParseCompileCommandsFlags should fall back to files in the same directory):
|
||||||
noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c'))
|
noautocmd execute 'file! ' . fnameescape(ale#path#Simplify('/foo/bar/xmms2-mpris/src/xmms2-mpris.c'))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user