Skip to content

Commit

Permalink
Defer highlights while in visual mode
Browse files Browse the repository at this point in the history
Fixes #45
  • Loading branch information
natebosch committed Nov 24, 2017
1 parent 846d02d commit 982a395
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions autoload/lsc/highlights.vim
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
" Refresh highlight matches on all visible windows.
function! lsc#highlights#updateDisplayed() abort
if s:DeferForSelect() | return | endif
if s:DeferForMode() | return | endif
call lsc#util#winDo('call lsc#highlights#update()')
endfunction

Expand Down Expand Up @@ -30,12 +30,13 @@ function! lsc#highlights#clear() abort
let w:lsc_diagnostic_matches = []
endfunction

" If vim is in select mode return true and attempt to schedule an update to
" highlights for after returning to normal mode. If vim enters insert mode the
" text will be changed and highlights will update anyway.
function! s:DeferForSelect() abort
" If vim is in select or visual mode return true and attempt to schedule an
" update to highlights for after returning to normal mode. If vim enters insert
" mode the text will be changed and highlights will update anyway.
function! s:DeferForMode() abort
let mode = mode()
if mode == 's' || mode == 'S' || mode == '\<c-s>'
if mode == 's' || mode == 'S' || mode == '\<c-s>' ||
\ mode == 'v' || mode == 'V' || mode == '\<c-v>'
call lsc#util#once('CursorHold,CursorMoved',
\ function('lsc#highlights#updateDisplayed'))
return v:true
Expand Down

0 comments on commit 982a395

Please sign in to comment.