vim:au: Defer selection highlighting by 100ms too
This makes moving the cursor in visual mode more responsive.
This commit is contained in:
@@ -112,6 +112,21 @@ function! HighlightVisualSel()
|
|||||||
|
|
||||||
call ClearHighlights(s:CLEAR_HIGHS_VISUAL)
|
call ClearHighlights(s:CLEAR_HIGHS_VISUAL)
|
||||||
|
|
||||||
|
" Delay the highlight by 100ms so that not every selection is highlighted
|
||||||
|
" while moving the cursor fast. (This kind of simulates a CursorHold
|
||||||
|
" event with a custom time)
|
||||||
|
if exists('w:selection_timer_id')
|
||||||
|
" Abort the already running timer and its callback
|
||||||
|
call timer_stop(w:selection_timer_id)
|
||||||
|
endif
|
||||||
|
let w:selection_timer_id = timer_start(100, "_HighlightVisualSel")
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! _HighlightVisualSel(timer)
|
||||||
|
if exists('w:selection_timer_id')
|
||||||
|
unlet w:selection_timer_id
|
||||||
|
endif
|
||||||
|
|
||||||
let l:old_reg = getreg('"')
|
let l:old_reg = getreg('"')
|
||||||
let l:old_regtype = getregtype('"')
|
let l:old_regtype = getregtype('"')
|
||||||
" NOTE: The yank needs to be silent to mute the 'n lines yanked'
|
" NOTE: The yank needs to be silent to mute the 'n lines yanked'
|
||||||
@@ -157,13 +172,19 @@ function! ClearHighlights(what = s:CLEAR_HIGHS_ALL)
|
|||||||
unlet w:cword_timer_id
|
unlet w:cword_timer_id
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
if and(a:what, s:CLEAR_HIGHS_VISUAL) && exists('w:visual_match_ids')
|
if and(a:what, s:CLEAR_HIGHS_VISUAL)
|
||||||
for l:pairs in w:visual_match_ids
|
if exists('w:visual_match_ids')
|
||||||
let l:id = l:pairs[0]
|
for l:pairs in w:visual_match_ids
|
||||||
let l:win = l:pairs[1]
|
let l:id = l:pairs[0]
|
||||||
call matchdelete(l:id, l:win)
|
let l:win = l:pairs[1]
|
||||||
endfor
|
call matchdelete(l:id, l:win)
|
||||||
unlet w:visual_match_ids
|
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
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user