aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-05 22:52:10 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-05 22:52:10 +1200
commitcbdb61b624caa1670e091f901c2bdd7e76e05414 (patch)
treec4eb163b3ce0cfa5963cba0d7b4031249e9fc02f
parent8679b3bb7124d3fe44d260ebec202c92d6695bcc (diff)
parent269c464e1246622ae7eeae6ade44182edf816995 (diff)
downloadvim-insert-suspend-hlsearch-master.tar.gz
vim-insert-suspend-hlsearch-master.zip
Merge branch 'release/v2.1.0'HEADv2.1.0master
* release/v2.1.0: Further refactor/simplify
-rw-r--r--VERSION2
-rw-r--r--autoload/insert_suspend_hlsearch.vim13
2 files changed, 11 insertions, 4 deletions
diff --git a/VERSION b/VERSION
index 227cea2..7ec1d6d 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.0.0
+2.1.0
diff --git a/autoload/insert_suspend_hlsearch.vim b/autoload/insert_suspend_hlsearch.vim
index de43d10..4408d52 100644
--- a/autoload/insert_suspend_hlsearch.vim
+++ b/autoload/insert_suspend_hlsearch.vim
@@ -1,8 +1,15 @@
-" Save value of 'hlsearch' into a variable, and disable it
+" Suspend 'hlsearch' if set, add hook to restore on insert completion
function! insert_suspend_hlsearch#() abort
- let s:hlsearch = &hlsearch
+
+ " Nothing to do if 'hlsearch' isn't set
+ if !&hlsearch
+ return
+ endif
+
+ " Turn off 'hlsearch' and set a hook to re-enable it when insert mode ends
set nohlsearch
autocmd insert_suspend_hlsearch InsertLeave *
- \ let &hlsearch = s:hlsearch
+ \ set hlsearch
\|autocmd! insert_suspend_hlsearch InsertLeave
+
endfunction