Defensive coding against stepping over other plugins' signs.

This commit is contained in:
LCD 47 2014-07-16 09:34:27 +03:00
parent 6c88bae55d
commit 1e3e0a8254
2 changed files with 19 additions and 11 deletions

View File

@ -19,7 +19,7 @@ if has('reltime')
lockvar! g:syntastic_start lockvar! g:syntastic_start
endif endif
let g:syntastic_version = '3.4.0-105' let g:syntastic_version = '3.4.0-106'
lockvar g:syntastic_version lockvar g:syntastic_version
" Sanity checks {{{1 " Sanity checks {{{1

View File

@ -42,7 +42,6 @@ function! g:SyntasticSignsNotifier.refresh(loclist) " {{{2
call self._signErrors(a:loclist) call self._signErrors(a:loclist)
endif endif
call self._removeSigns(old_signs) call self._removeSigns(old_signs)
let s:first_sign_id = exists('s:next_sign_id') ? s:next_sign_id : 5000
endfunction " }}}2 endfunction " }}}2
" }}}1 " }}}1
@ -96,18 +95,27 @@ function! g:SyntasticSignsNotifier._signErrors(loclist) " {{{2
let seen = {} let seen = {}
for i in issues for i in issues
if !has_key(seen, i['lnum']) if i['lnum'] > 0 && !has_key(seen, i['lnum'])
let seen[i['lnum']] = 1 let seen[i['lnum']] = 1
if i['lnum'] > 0 let sign_severity = i['type'] ==? 'W' ? 'Warning' : 'Error'
let sign_severity = i['type'] ==? 'W' ? 'Warning' : 'Error' let sign_subtype = get(i, 'subtype', '')
let sign_subtype = get(i, 'subtype', '') let sign_type = 'Syntastic' . sign_subtype . sign_severity
let sign_type = 'Syntastic' . sign_subtype . sign_severity let where = " line=" . i['lnum'] . " name=" . sign_type . " buffer=" . i['bufnr']
execute "sign place " . s:next_sign_id . " line=" . i['lnum'] . " name=" . sign_type . " buffer=" . i['bufnr'] " try to find a free ID
call add(self._bufSignIds(), s:next_sign_id) " XXX: this can turn into an infinite loop
let s:next_sign_id += 1 let done = 0
endif while !done
try
execute "sign place " . s:next_sign_id . where
call add(self._bufSignIds(), s:next_sign_id)
let s:next_sign_id += 1
let done = 1
catch /\m^Vim\%((\a\+)\)\=:E885/
let s:next_sign_id += 500
endtry
endwhile
endif endif
endfor endfor
endif endif