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:
LCD 47 2013-06-10 23:14:59 +03:00
parent 197ca09edd
commit 6574872b55
2 changed files with 26 additions and 7 deletions

View File

@ -122,10 +122,14 @@ endfunction
" Returns unique elements in a list
function! syntastic#util#unique(list)
let seen = {}
let uniques = []
for e in a:list
let seen[e] = 1
if !has_key(seen, e)
let seen[e] = 1
call add(uniques, e)
endif
endfor
return copy(keys(seen))
return uniques
endfunction
function! syntastic#util#debug(msg)

View File

@ -64,7 +64,7 @@ endfunction
function! g:SyntasticRegistry.getActiveCheckers(ftalias)
let filetype = s:SyntasticRegistryNormaliseFiletype(a:ftalias)
let checkers = self.availableCheckersFor(filetype)
let checkers = self.availableCheckersFor(a:ftalias)
if self._userHasFiletypeSettings(filetype)
return self._filterCheckersByUserSettings(checkers, filetype)
@ -126,8 +126,7 @@ endfunction
function! g:SyntasticRegistry._filterCheckersByDefaultSettings(checkers, filetype)
if has_key(s:defaultCheckers, a:filetype)
let whitelist = s:defaultCheckers[a:filetype]
return filter(a:checkers, "index(whitelist, v:val.getName()) != -1")
return self._filterCheckersByName(a:checkers, s:defaultCheckers[a:filetype])
endif
return a:checkers
@ -139,11 +138,27 @@ function! g:SyntasticRegistry._filterCheckersByUserSettings(checkers, filetype)
else
let whitelist = g:syntastic_{a:filetype}_checkers
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
function! g:SyntasticRegistry._filterCheckersByAvailability(checkers)
return filter(a:checkers, "v:val.isAvailable()")
return filter(copy(a:checkers), "v:val.isAvailable()")
endfunction
function! g:SyntasticRegistry._loadCheckers(filetype)