aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-05 22:26:13 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-05 22:26:13 +1200
commita4ba229d16deddd09b2cb60d28958ad142600a52 (patch)
tree63ad143a2245dbe29fe4ee9f8534f1db2c700407 /autoload
parentMerge branch 'release/v1.0.0' into develop (diff)
downloadvim-insert-suspend-hlsearch-a4ba229d16deddd09b2cb60d28958ad142600a52.tar.gz
vim-insert-suspend-hlsearch-a4ba229d16deddd09b2cb60d28958ad142600a52.zip
Refactor with dynamic autocmd hook
Diffstat (limited to 'autoload')
-rw-r--r--autoload/insert_suspend_hlsearch.vim16
1 files changed, 5 insertions, 11 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