Preserve order in checker lists. Fixes #684.
Keep order from g:syntastic_[filetype]_checkers and s:defaultCheckers in getActiveCheckers(). Keep order in syntastic#util#unique().
This commit is contained in:
parent
197ca09edd
commit
6574872b55
@ -122,10 +122,14 @@ endfunction
|
|||||||
" Returns unique elements in a list
|
" Returns unique elements in a list
|
||||||
function! syntastic#util#unique(list)
|
function! syntastic#util#unique(list)
|
||||||
let seen = {}
|
let seen = {}
|
||||||
|
let uniques = []
|
||||||
for e in a:list
|
for e in a:list
|
||||||
|
if !has_key(seen, e)
|
||||||
let seen[e] = 1
|
let seen[e] = 1
|
||||||
|
call add(uniques, e)
|
||||||
|
endif
|
||||||
endfor
|
endfor
|
||||||
return copy(keys(seen))
|
return uniques
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! syntastic#util#debug(msg)
|
function! syntastic#util#debug(msg)
|
||||||
|
@ -64,7 +64,7 @@ endfunction
|
|||||||
|
|
||||||
function! g:SyntasticRegistry.getActiveCheckers(ftalias)
|
function! g:SyntasticRegistry.getActiveCheckers(ftalias)
|
||||||
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
|
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
|
||||||
let checkers = self.availableCheckersFor(filetype)
|
let checkers = self.availableCheckersFor(a:ftalias)
|
||||||
|
|
||||||
if self._userHasFiletypeSettings(filetype)
|
if self._userHasFiletypeSettings(filetype)
|
||||||
return self._filterCheckersByUserSettings(checkers, filetype)
|
return self._filterCheckersByUserSettings(checkers, filetype)
|
||||||
@ -126,8 +126,7 @@ endfunction
|
|||||||
|
|
||||||
function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype)
|
function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype)
|
||||||
if has_key(s:defaultCheckers, a:filetype)
|
if has_key(s:defaultCheckers, a:filetype)
|
||||||
let whitelist = s:defaultCheckers[a:filetype]
|
return self._filterCheckersByName(a:checkers, s:defaultCheckers[a:filetype])
|
||||||
return filter(a:checkers, "index(whitelist, v:val.getName()) != -1")
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
return a:checkers
|
return a:checkers
|
||||||
@ -139,11 +138,27 @@ function! g:SyntasticRegistry._filterCheckersByUserSettings(checkers, filetype)
|
|||||||
else
|
else
|
||||||
let whitelist = g:syntastic_{a:filetype}_checkers
|
let whitelist = g:syntastic_{a:filetype}_checkers
|
||||||
endif
|
endif
|
||||||
return filter(a:checkers, "index(whitelist, v:val.getName()) != -1")
|
return self._filterCheckersByName(a:checkers, whitelist)
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! g:SyntasticRegistry._filterCheckersByName(checkers, list)
|
||||||
|
let checkers_by_name = {}
|
||||||
|
for c in a:checkers
|
||||||
|
let checkers_by_name[c.getName()] = c
|
||||||
|
endfor
|
||||||
|
|
||||||
|
let filtered = []
|
||||||
|
for name in a:list
|
||||||
|
if has_key(checkers_by_name, name)
|
||||||
|
call add(filtered, checkers_by_name[name])
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
return filtered
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticRegistry._filterCheckersByAvailability(checkers)
|
function! g:SyntasticRegistry._filterCheckersByAvailability(checkers)
|
||||||
return filter(a:checkers, "v:val.isAvailable()")
|
return filter(copy(a:checkers), "v:val.isAvailable()")
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticRegistry._loadCheckers(filetype)
|
function! g:SyntasticRegistry._loadCheckers(filetype)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user