Made SyntacticIsVersionAtLeast more robust
It now handles more cases, which will cause Syntastic to degrade better when commands return weird versions (e.g. the command crashes).
This commit is contained in:
parent
2003c772b0
commit
3dc0b6dc24
@ -509,17 +509,34 @@ function! s:uname()
|
|||||||
return s:uname
|
return s:uname
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"the args must be arrays of the form [major, minor, macro]
|
" Verify that the 'installed' version is at the 'required' version, if not
|
||||||
|
" better.
|
||||||
|
"
|
||||||
|
" 'installed' and 'required' must be arrays. Only the
|
||||||
|
" first three elements (major, minor, patch) are looked at.
|
||||||
|
"
|
||||||
|
" Either array may be less than three elements. The "missing" elements
|
||||||
|
" will be assumed to be '0' for the purposes of checking.
|
||||||
|
"
|
||||||
|
" See http://semver.org for info about version numbers.
|
||||||
function SyntasticIsVersionAtLeast(installed, required)
|
function SyntasticIsVersionAtLeast(installed, required)
|
||||||
if a:installed[0] != a:required[0]
|
for index in [0,1,2]
|
||||||
return a:installed[0] > a:required[0]
|
if len(a:installed) <= index
|
||||||
endif
|
let installed_element = 0
|
||||||
|
else
|
||||||
if a:installed[1] != a:required[1]
|
let installed_element = a:installed[index]
|
||||||
return a:installed[1] > a:required[1]
|
endif
|
||||||
endif
|
if len(a:required) <= index
|
||||||
|
let required_element = 0
|
||||||
return a:installed[2] >= a:required[2]
|
else
|
||||||
|
let required_element = a:required[index]
|
||||||
|
endif
|
||||||
|
if installed_element != required_element
|
||||||
|
return installed_element > required_element
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
" Everything matched, so it is at least the required version.
|
||||||
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"return a string representing the state of buffer according to
|
"return a string representing the state of buffer according to
|
||||||
|
Loading…
Reference in New Issue
Block a user