aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-05 22:28:05 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-05 22:28:05 +1200
commit8679b3bb7124d3fe44d260ebec202c92d6695bcc (patch)
tree4a1014ff0687647696ddc764b3b3f035f7ff8b55
parentMerge branch 'release/v1.0.0' (diff)
parentBump VERSION (diff)
downloadvim-insert-suspend-hlsearch-8679b3bb7124d3fe44d260ebec202c92d6695bcc.tar.gz
vim-insert-suspend-hlsearch-8679b3bb7124d3fe44d260ebec202c92d6695bcc.zip
Merge branch 'release/v2.0.0'v2.0.0
* release/v2.0.0: Refactor with dynamic autocmd hook
-rw-r--r--VERSION2
-rw-r--r--autoload/insert_suspend_hlsearch.vim16
-rw-r--r--plugin/insert_suspend_hlsearch.vim4
3 files changed, 7 insertions, 15 deletions
diff --git a/VERSION b/VERSION
index 3eefcb9..227cea2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.0
+2.0.0
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