vim:au: Work around additional call of _highlight_cword
Sometimes `_highlight_cword` is called without the existence of
w:cword_timer_id but with a w:cword_match_id. No idea why.
I thought that it might be a race condition, but does not seem like it.
(Also not sure if this could even run in parallel)
TODO: Investigate how _highlight_cword can be called without
w:cword_timer_id
This commit is contained in:
@@ -84,6 +84,11 @@ function! s:highlight_cword()
|
||||
endfunction
|
||||
|
||||
function! s:_highlight_cword(timer_id)
|
||||
" TODO: this should never exist, but sometimes it does. How? To reproduce:
|
||||
" Select something and then <leader>nr.
|
||||
if exists('w:cword_match_id')
|
||||
return
|
||||
endif
|
||||
unlet w:cword_timer_id
|
||||
|
||||
let l:cword = expand('<cword>')
|
||||
@@ -160,27 +165,27 @@ endfunction
|
||||
" Clear the highlights of <cword> and visual selection
|
||||
function! s:clear_highlights(what = s:CLEAR_HIGHS_ALL)
|
||||
if and(a:what, s:CLEAR_HIGHS_CWORD)
|
||||
if exists('w:cword_timer_id')
|
||||
call timer_stop(w:cword_timer_id)
|
||||
unlet w:cword_timer_id
|
||||
endif
|
||||
if exists('w:cword_match_id')
|
||||
call matchdelete(w:cword_match_id)
|
||||
unlet w:cword_match_id
|
||||
unlet w:old_cword
|
||||
endif
|
||||
if exists('w:cword_timer_id')
|
||||
call timer_stop(w:cword_timer_id)
|
||||
unlet w:cword_timer_id
|
||||
endif
|
||||
endif
|
||||
if and(a:what, s:CLEAR_HIGHS_VISUAL)
|
||||
if exists('w:selection_timer_id')
|
||||
call timer_stop(w:selection_timer_id)
|
||||
unlet w:selection_timer_id
|
||||
endif
|
||||
if exists('w:visual_match_ids')
|
||||
for [l:win, l:id] in items(w:visual_match_ids)
|
||||
call matchdelete(l:id, l:win)
|
||||
endfor
|
||||
unlet w:visual_match_ids
|
||||
endif
|
||||
if exists('w:selection_timer_id')
|
||||
call timer_stop(w:selection_timer_id)
|
||||
unlet w:selection_timer_id
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
Reference in New Issue
Block a user