aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-07-12 12:45:36 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-07-12 12:45:36 +1200
commite5f9e3a8985ee0e038324ce493b7b6833e92b9f5 (patch)
tree243e7b7cd139bbcd405443a6e4c6d6b51bd2cd43
parentMerge branch 'release/v0.5.0' (diff)
parentBump VERSION (diff)
downloadvim-insert-suspend-hlsearch-0.6.0.tar.gz (sig)
vim-insert-suspend-hlsearch-0.6.0.zip
Merge branch 'release/v0.6.0'v0.6.0
* release/v0.6.0: Bump VERSION Remove autoload
-rw-r--r--VERSION2
-rw-r--r--autoload/insert_suspend_hlsearch.vim20
-rw-r--r--plugin/insert_suspend_hlsearch.vim25
3 files changed, 24 insertions, 23 deletions
diff --git a/VERSION b/VERSION
index 8f0916f..a918a2a 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.5.0
+0.6.0
diff --git a/autoload/insert_suspend_hlsearch.vim b/autoload/insert_suspend_hlsearch.vim
deleted file mode 100644
index 2638abc..0000000
--- a/autoload/insert_suspend_hlsearch.vim
+++ /dev/null
@@ -1,20 +0,0 @@
-" Initialise option saving variable
-let s:hlsearch = &hlsearch
-
-" Save the current value of the 'hlsearch' option in a script variable, and
-" disable it if enabled. Note that :nohlsearch does not work for this; see
-" :help autocmd-searchpat.
-function! insert_suspend_hlsearch#Suspend() abort
- let s:hlsearch = &hlsearch
- if s:hlsearch
- set nohlsearch
- endif
-endfunction
-
-" Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was
-" called.
-function! insert_suspend_hlsearch#Restore() abort
- if s:hlsearch
- set hlsearch
- endif
-endfunction
diff --git a/plugin/insert_suspend_hlsearch.vim b/plugin/insert_suspend_hlsearch.vim
index 5dd1e74..5d199f7 100644
--- a/plugin/insert_suspend_hlsearch.vim
+++ b/plugin/insert_suspend_hlsearch.vim
@@ -14,10 +14,31 @@ if !has('autocmd') || !has('extra_search') || v:version < 700
endif
let g:loaded_insert_suspend_hlsearch = 1
+" Initialise option saving variable
+let s:hlsearch_save = &hlsearch
+
+" Save the current value of the 'hlsearch' option in a script variable, and
+" disable it if enabled. Note that :nohlsearch does not work for this; see
+" :help autocmd-searchpat.
+function! s:Suspend() abort
+ let s:hlsearch_save = &hlsearch
+ if &hlsearch
+ set nohlsearch
+ endif
+endfunction
+
+" Restore the value of 'hlsearch' from the last time s:HlsearchSuspend was
+" called.
+function! s:Restore() abort
+ if !&hlsearch && s:hlsearch_save
+ set hlsearch
+ endif
+endfunction
+
" Clear search highlighting as soon as I enter insert mode, and restore it
" once left
augroup insert_suspend_hlsearch
autocmd!
- autocmd InsertEnter * call insert_suspend_hlsearch#Suspend()
- autocmd InsertLeave * call insert_suspend_hlsearch#Restore()
+ autocmd InsertEnter * call s:Suspend()
+ autocmd InsertLeave * call s:Restore()
augroup END