From a4ba229d16deddd09b2cb60d28958ad142600a52 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Jun 2019 22:26:13 +1200 Subject: Refactor with dynamic autocmd hook --- autoload/insert_suspend_hlsearch.vim | 16 +++++----------- plugin/insert_suspend_hlsearch.vim | 4 +--- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/autoload/insert_suspend_hlsearch.vim b/autoload/insert_suspend_hlsearch.vim index 4961ed9..de43d10 100644 --- a/autoload/insert_suspend_hlsearch.vim +++ b/autoload/insert_suspend_hlsearch.vim @@ -1,14 +1,8 @@ " Save value of 'hlsearch' into a variable, and disable it -function! insert_suspend_hlsearch#Suspend() abort +function! insert_suspend_hlsearch#() abort let s:hlsearch = &hlsearch - let &hlsearch = 0 -endfunction - -" Restore the value of 'hlsearch' if suspended -function! insert_suspend_hlsearch#Restore() abort - if !exists('s:hlsearch') - return - endif - let &hlsearch = s:hlsearch - unlet s:hlsearch + set nohlsearch + autocmd insert_suspend_hlsearch InsertLeave * + \ let &hlsearch = s:hlsearch + \|autocmd! insert_suspend_hlsearch InsertLeave endfunction diff --git a/plugin/insert_suspend_hlsearch.vim b/plugin/insert_suspend_hlsearch.vim index 2a88e8a..4b601e5 100644 --- a/plugin/insert_suspend_hlsearch.vim +++ b/plugin/insert_suspend_hlsearch.vim @@ -16,7 +16,5 @@ let loaded_insert_suspend_hlsearch = 1 augroup insert_suspend_hlsearch autocmd! autocmd InsertEnter * - \ call insert_suspend_hlsearch#Suspend() - autocmd InsertLeave * - \ call insert_suspend_hlsearch#Restore() + \ call insert_suspend_hlsearch#() augroup END -- cgit v1.2.3 From fd99bfd2133e481479021b1aeeb7904512871ff0 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Wed, 5 Jun 2019 22:27:55 +1200 Subject: Bump VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 3eefcb9..227cea2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +2.0.0 -- cgit v1.2.3