Refresh optimisations.
This commit is contained in:
parent
572d3e0ebc
commit
d364f33a53
@ -154,17 +154,10 @@ function! s:logRedirect(on) " {{{2
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:logTimestamp_smart() " {{{2
|
||||
function! s:logTimestamp() " {{{2
|
||||
return 'syntastic: ' . split(reltimestr(reltime(g:syntastic_start)))[0] . ': '
|
||||
endfunction " }}}2
|
||||
|
||||
function! s:logTimestamp_dumb() " {{{2
|
||||
return 'syntastic: debug: '
|
||||
endfunction " }}}2
|
||||
|
||||
let s:logTimestamp = function(has('reltime') ? 's:logTimestamp_smart' : 's:logTimestamp_dumb')
|
||||
lockvar s:logTimestamp
|
||||
|
||||
function! s:formatVariable(name) " {{{2
|
||||
let vals = []
|
||||
if exists('g:syntastic_' . a:name)
|
||||
|
@ -226,6 +226,12 @@ function! syntastic#util#sortLoclist(errors) " {{{2
|
||||
call sort(a:errors, 's:compareErrorItems')
|
||||
endfunction " }}}2
|
||||
|
||||
" Return a floating point number, representing the time
|
||||
" (hopefully high resolution) since program start
|
||||
function! syntastic#util#timestamp() " {{{2
|
||||
return str2float(reltimestr(reltime(g:syntastic_start)))
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" Private functions {{{1
|
||||
|
@ -19,12 +19,12 @@ if has('reltime')
|
||||
lockvar! g:syntastic_start
|
||||
endif
|
||||
|
||||
let g:syntastic_version = '3.4.0-95'
|
||||
let g:syntastic_version = '3.4.0-96'
|
||||
lockvar g:syntastic_version
|
||||
|
||||
" Sanity checks {{{1
|
||||
|
||||
for s:feature in ['autocmd', 'eval', 'modify_fname', 'quickfix', 'user_commands']
|
||||
for s:feature in ['autocmd', 'eval', 'modify_fname', 'quickfix', 'reltime', 'user_commands']
|
||||
if !has(s:feature)
|
||||
call syntastic#log#error("need Vim compiled with feature " . s:feature)
|
||||
finish
|
||||
@ -376,7 +376,6 @@ function! s:CacheErrors(checker_names) " {{{2
|
||||
endif
|
||||
endif
|
||||
|
||||
call newLoclist.setOwner(bufnr(''))
|
||||
call newLoclist.deploy()
|
||||
endfunction " }}}2
|
||||
|
||||
|
@ -43,6 +43,7 @@ endfunction " }}}2
|
||||
" Reset the error balloons
|
||||
" @vimlint(EVL103, 1, a:loclist)
|
||||
function! g:SyntasticBalloonsNotifier.reset(loclist) " {{{2
|
||||
let b:syntastic_balloons = {}
|
||||
if has('balloon_eval')
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'balloons: reset')
|
||||
set nobeval
|
||||
|
@ -32,8 +32,8 @@ endfunction " }}}2
|
||||
" Sets error highlights in the cuirrent window
|
||||
function! g:SyntasticHighlightingNotifier.refresh(loclist) " {{{2
|
||||
if self.enabled()
|
||||
call self.reset(a:loclist)
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'highlighting: refresh')
|
||||
call self._reset()
|
||||
let buf = bufnr('')
|
||||
let issues = filter(a:loclist.copyRaw(), 'v:val["bufnr"] == buf')
|
||||
for item in issues
|
||||
@ -64,11 +64,7 @@ endfunction " }}}2
|
||||
function! g:SyntasticHighlightingNotifier.reset(loclist) " {{{2
|
||||
if s:has_highlighting
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'highlighting: reset')
|
||||
for match in getmatches()
|
||||
if stridx(match['group'], 'Syntastic') == 0
|
||||
call matchdelete(match['id'])
|
||||
endif
|
||||
endfor
|
||||
call self._reset()
|
||||
endif
|
||||
endfunction " }}}2
|
||||
" @vimlint(EVL103, 0, a:loclist)
|
||||
@ -95,6 +91,14 @@ function! g:SyntasticHighlightingNotifier._setup() " {{{2
|
||||
endif
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticHighlightingNotifier._reset() " {{{2
|
||||
for match in getmatches()
|
||||
if stridx(match['group'], 'Syntastic') == 0
|
||||
call matchdelete(match['id'])
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}2
|
||||
|
||||
" }}}1
|
||||
|
||||
" vim: set sw=4 sts=4 et fdm=marker:
|
||||
|
@ -46,6 +46,13 @@ function! g:SyntasticLoclist.isEmpty() " {{{2
|
||||
return empty(self._rawLoclist)
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.isNewer(stamp) " {{{2
|
||||
if !exists("self._stamp")
|
||||
let self._stamp = -1.0
|
||||
endif
|
||||
return self._stamp > a:stamp
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.copyRaw() " {{{2
|
||||
return copy(self._rawLoclist)
|
||||
endfunction " }}}2
|
||||
@ -132,6 +139,8 @@ function! g:SyntasticLoclist.setOwner(buffer) " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticLoclist.deploy() " {{{2
|
||||
call self.setOwner(bufnr(''))
|
||||
let self._stamp = syntastic#util#timestamp()
|
||||
for buf in self.getBuffers()
|
||||
call setbufvar(buf, 'syntastic_loclist', self)
|
||||
endfor
|
||||
|
@ -8,6 +8,9 @@ let g:SyntasticNotifiers = {}
|
||||
let s:notifier_types = ['signs', 'balloons', 'highlighting', 'cursor', 'autoloclist']
|
||||
lockvar! s:notifier_types
|
||||
|
||||
let s:persistent_notifiers = ['signs', 'balloons']
|
||||
lockvar! s:persistent_notifiers
|
||||
|
||||
" Public methods {{{1
|
||||
|
||||
function! g:SyntasticNotifiers.Instance() " {{{2
|
||||
@ -20,11 +23,27 @@ function! g:SyntasticNotifiers.Instance() " {{{2
|
||||
endfunction " }}}2
|
||||
|
||||
function! g:SyntasticNotifiers.refresh(loclist) " {{{2
|
||||
if !a:loclist.isEmpty() && !a:loclist.isNewer(0.0)
|
||||
" loclist not fully constructed yet
|
||||
return
|
||||
endif
|
||||
|
||||
call syntastic#log#debug(g:SyntasticDebugNotifications, 'notifiers: refresh')
|
||||
for type in self._enabled_types
|
||||
let class = substitute(type, '\m.*', 'Syntastic\u&Notifier', '')
|
||||
if !has_key(g:{class}, 'enabled') || self._notifier[type].enabled()
|
||||
call self._notifier[type].refresh(a:loclist)
|
||||
if index(s:persistent_notifiers, type) > -1
|
||||
" refresh only if loclist has changed since last call
|
||||
if !exists('b:syntastic_' . type . '_timestamp')
|
||||
let b:syntastic_{type}_timestamp = -1.0
|
||||
endif
|
||||
if a:loclist.isNewer(b:syntastic_{type}_timestamp)
|
||||
call self._notifier[type].refresh(a:loclist)
|
||||
let b:syntastic_{type}_timestamp = syntastic#util#timestamp()
|
||||
endif
|
||||
else
|
||||
call self._notifier[type].refresh(a:loclist)
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}2
|
||||
@ -40,6 +59,11 @@ function! g:SyntasticNotifiers.reset(loclist) " {{{2
|
||||
if has_key(g:{class}, 'reset')
|
||||
call self._notifier[type].reset(a:loclist)
|
||||
endif
|
||||
|
||||
" also reset timestamps
|
||||
if index(s:persistent_notifiers, type) > -1
|
||||
let b:syntastic_{type}_timestamp = -1.0
|
||||
endif
|
||||
endfor
|
||||
endfunction " }}}2
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user