From 982a39596ff118b38cb007af18ceec9a3a3607c8 Mon Sep 17 00:00:00 2001 From: Nate Bosch Date: Fri, 24 Nov 2017 13:48:12 -0800 Subject: [PATCH] Defer highlights while in visual mode Fixes #45 --- autoload/lsc/highlights.vim | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/autoload/lsc/highlights.vim b/autoload/lsc/highlights.vim index 4e865753..8710a5d9 100644 --- a/autoload/lsc/highlights.vim +++ b/autoload/lsc/highlights.vim @@ -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 @@ -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 == '\' + if mode == 's' || mode == 'S' || mode == '\' || + \ mode == 'v' || mode == 'V' || mode == '\' call lsc#util#once('CursorHold,CursorMoved', \ function('lsc#highlights#updateDisplayed')) return v:true