Bug fix: add enabled/disabled guards to notifiers.
Also handle the case when user disables notifiers after the first run. This doesn't work for signs though, since it causes an ugly flicker in the common case.
This commit is contained in:
parent
6a0dc699e0
commit
e291f9f06d
@ -21,13 +21,15 @@ function! g:SyntasticBalloonsNotifier.New()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticBalloonsNotifier.enabled()
|
function! g:SyntasticBalloonsNotifier.enabled()
|
||||||
return exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons
|
return
|
||||||
|
\ has('balloon_eval') &&
|
||||||
|
\ (exists('b:syntastic_enable_balloons') ? b:syntastic_enable_balloons : g:syntastic_enable_balloons)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Update the error balloons
|
" Update the error balloons
|
||||||
function! g:SyntasticBalloonsNotifier.refresh(loclist)
|
function! g:SyntasticBalloonsNotifier.refresh(loclist)
|
||||||
let b:syntastic_balloons = {}
|
let b:syntastic_balloons = {}
|
||||||
if a:loclist.hasErrorsOrWarningsToDisplay()
|
if self.enabled() && a:loclist.hasErrorsOrWarningsToDisplay()
|
||||||
let buf = bufnr('')
|
let buf = bufnr('')
|
||||||
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
|
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
|
||||||
if !empty(issues)
|
if !empty(issues)
|
||||||
@ -45,7 +47,9 @@ endfunction
|
|||||||
|
|
||||||
" Reset the error balloons
|
" Reset the error balloons
|
||||||
function! g:SyntasticBalloonsNotifier.reset(loclist)
|
function! g:SyntasticBalloonsNotifier.reset(loclist)
|
||||||
set nobeval
|
if has('balloon_eval')
|
||||||
|
set nobeval
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Private functions {{{1
|
" Private functions {{{1
|
||||||
|
@ -16,9 +16,12 @@ function! g:SyntasticCursorNotifier.New()
|
|||||||
return newObj
|
return newObj
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! g:SyntasticCursorNotifier.enabled()
|
||||||
|
return exists('b:syntastic_echo_current_error') ? b:syntastic_echo_current_error : g:syntastic_echo_current_error
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticCursorNotifier.refresh(loclist)
|
function! g:SyntasticCursorNotifier.refresh(loclist)
|
||||||
let enabled = exists('b:syntastic_echo_current_error') ? b:syntastic_echo_current_error : g:syntastic_echo_current_error
|
if self.enabled() && a:loclist.hasErrorsOrWarningsToDisplay()
|
||||||
if enabled && a:loclist.hasErrorsOrWarningsToDisplay()
|
|
||||||
let b:syntastic_messages = copy(a:loclist.messages(bufnr('')))
|
let b:syntastic_messages = copy(a:loclist.messages(bufnr('')))
|
||||||
let b:oldLine = -1
|
let b:oldLine = -1
|
||||||
autocmd! syntastic CursorMoved
|
autocmd! syntastic CursorMoved
|
||||||
|
@ -3,15 +3,13 @@ if exists("g:loaded_syntastic_notifier_highlighting")
|
|||||||
endif
|
endif
|
||||||
let g:loaded_syntastic_notifier_highlighting = 1
|
let g:loaded_syntastic_notifier_highlighting = 1
|
||||||
|
|
||||||
|
" Highlighting requires getmatches introduced in 7.1.040
|
||||||
|
let s:has_highlighting = v:version > 701 || (v:version == 701 && has('patch040'))
|
||||||
|
|
||||||
if !exists("g:syntastic_enable_highlighting")
|
if !exists("g:syntastic_enable_highlighting")
|
||||||
let g:syntastic_enable_highlighting = 1
|
let g:syntastic_enable_highlighting = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Highlighting requires getmatches introduced in 7.1.040
|
|
||||||
if v:version < 701 || (v:version == 701 && !has('patch040'))
|
|
||||||
let g:syntastic_enable_highlighting = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
let g:SyntasticHighlightingNotifier = {}
|
let g:SyntasticHighlightingNotifier = {}
|
||||||
|
|
||||||
" Public methods {{{1
|
" Public methods {{{1
|
||||||
@ -22,41 +20,47 @@ function! g:SyntasticHighlightingNotifier.New()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticHighlightingNotifier.enabled()
|
function! g:SyntasticHighlightingNotifier.enabled()
|
||||||
return exists('b:syntastic_enable_highlighting') ? b:syntastic_enable_highlighting : g:syntastic_enable_highlighting
|
return
|
||||||
|
\ s:has_highlighting &&
|
||||||
|
\ (exists('b:syntastic_enable_highlighting') ? b:syntastic_enable_highlighting : g:syntastic_enable_highlighting)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Sets error highlights in the cuirrent window
|
" Sets error highlights in the cuirrent window
|
||||||
function! g:SyntasticHighlightingNotifier.refresh(loclist)
|
function! g:SyntasticHighlightingNotifier.refresh(loclist)
|
||||||
call self.reset(a:loclist)
|
if self.enabled()
|
||||||
let buf = bufnr('')
|
call self.reset(a:loclist)
|
||||||
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
|
let buf = bufnr('')
|
||||||
for item in issues
|
let issues = filter(a:loclist.filteredRaw(), 'v:val["bufnr"] == buf')
|
||||||
let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning'
|
for item in issues
|
||||||
|
let group = item['type'] == 'E' ? 'SyntasticError' : 'SyntasticWarning'
|
||||||
|
|
||||||
" The function `Syntastic_{filetype}_{checker}_GetHighlightRegex` is
|
" The function `Syntastic_{filetype}_{checker}_GetHighlightRegex` is
|
||||||
" used to override default highlighting.
|
" used to override default highlighting.
|
||||||
if has_key(item, 'hl')
|
if has_key(item, 'hl')
|
||||||
call matchadd(group, '\%' . item['lnum'] . 'l' . item['hl'])
|
call matchadd(group, '\%' . item['lnum'] . 'l' . item['hl'])
|
||||||
elseif get(item, 'col')
|
elseif get(item, 'col')
|
||||||
let lastcol = col([item['lnum'], '$'])
|
let lastcol = col([item['lnum'], '$'])
|
||||||
let lcol = min([lastcol, item['col']])
|
let lcol = min([lastcol, item['col']])
|
||||||
|
|
||||||
" a bug in vim can sometimes cause there to be no 'vcol' key,
|
" a bug in vim can sometimes cause there to be no 'vcol' key,
|
||||||
" so check for its existence
|
" so check for its existence
|
||||||
let coltype = has_key(item, 'vcol') && item['vcol'] ? 'v' : 'c'
|
let coltype = has_key(item, 'vcol') && item['vcol'] ? 'v' : 'c'
|
||||||
|
|
||||||
call matchadd(group, '\%' . item['lnum'] . 'l\%' . lcol . coltype)
|
call matchadd(group, '\%' . item['lnum'] . 'l\%' . lcol . coltype)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Remove all error highlights from the window
|
" Remove all error highlights from the window
|
||||||
function! g:SyntasticHighlightingNotifier.reset(loclist)
|
function! g:SyntasticHighlightingNotifier.reset(loclist)
|
||||||
for match in getmatches()
|
if s:has_highlighting
|
||||||
if stridx(match['group'], 'Syntastic') == 0
|
for match in getmatches()
|
||||||
call matchdelete(match['id'])
|
if stridx(match['group'], 'Syntastic') == 0
|
||||||
endif
|
call matchdelete(match['id'])
|
||||||
endfor
|
endif
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim: set sw=4 sts=4 et fdm=marker:
|
" vim: set sw=4 sts=4 et fdm=marker:
|
||||||
|
@ -30,7 +30,11 @@ endfunction
|
|||||||
function! g:SyntasticNotifiers.reset(loclist)
|
function! g:SyntasticNotifiers.reset(loclist)
|
||||||
for type in self._enabled_types
|
for type in self._enabled_types
|
||||||
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
|
let class = substitute(type, '.*', 'Syntastic\u&Notifier', '')
|
||||||
if has_key(g:{class}, 'reset') && (!has_key(g:{class}, 'enabled') || self._notifier[type].enabled())
|
|
||||||
|
" reset notifiers regardless if they are enabled or not, since
|
||||||
|
" the user might have disabled them since the last refresh();
|
||||||
|
" notifiers MUST be prepared to deal with reset() when disabled
|
||||||
|
if has_key(g:{class}, 'reset')
|
||||||
call self._notifier[type].reset(a:loclist)
|
call self._notifier[type].reset(a:loclist)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
@ -23,10 +23,6 @@ if !exists("g:syntastic_style_warning_symbol")
|
|||||||
let g:syntastic_style_warning_symbol = 'S>'
|
let g:syntastic_style_warning_symbol = 'S>'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if !has('signs')
|
|
||||||
let g:syntastic_enable_signs = 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
" start counting sign ids at 5000, start here to hopefully avoid conflicting
|
" start counting sign ids at 5000, start here to hopefully avoid conflicting
|
||||||
" with any other code that places signs (not sure if this precaution is
|
" with any other code that places signs (not sure if this precaution is
|
||||||
@ -52,13 +48,16 @@ function! g:SyntasticSignsNotifier.New()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! g:SyntasticSignsNotifier.enabled()
|
function! g:SyntasticSignsNotifier.enabled()
|
||||||
return exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs
|
return
|
||||||
|
\ has('signs') &&
|
||||||
|
\ exists('b:syntastic_enable_signs') ? b:syntastic_enable_signs : g:syntastic_enable_signs
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Update the error signs
|
|
||||||
function! g:SyntasticSignsNotifier.refresh(loclist)
|
function! g:SyntasticSignsNotifier.refresh(loclist)
|
||||||
let old_signs = copy(self._bufSignIds())
|
let old_signs = copy(self._bufSignIds())
|
||||||
call self._signErrors(a:loclist)
|
if self.enabled()
|
||||||
|
call self._signErrors(a:loclist)
|
||||||
|
endif
|
||||||
call self._removeSigns(old_signs)
|
call self._removeSigns(old_signs)
|
||||||
let s:first_sign_id = s:next_sign_id
|
let s:first_sign_id = s:next_sign_id
|
||||||
endfunction
|
endfunction
|
||||||
@ -125,10 +124,12 @@ endfunction
|
|||||||
|
|
||||||
" Remove the signs with the given ids from this buffer
|
" Remove the signs with the given ids from this buffer
|
||||||
function! g:SyntasticSignsNotifier._removeSigns(ids)
|
function! g:SyntasticSignsNotifier._removeSigns(ids)
|
||||||
for i in a:ids
|
if has('signs')
|
||||||
exec "sign unplace " . i
|
for i in a:ids
|
||||||
call remove(self._bufSignIds(), index(self._bufSignIds(), i))
|
exec "sign unplace " . i
|
||||||
endfor
|
call remove(self._bufSignIds(), index(self._bufSignIds(), i))
|
||||||
|
endfor
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Get all the ids of the SyntaxError signs in the buffer
|
" Get all the ids of the SyntaxError signs in the buffer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user