aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-09-09 13:58:09 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-09-09 13:58:09 +1200
commitb48b57b35899796bfbea9a3aab8c584d8eaebfd5 (patch)
treedea8feef64974d9f74861b59c68128924d9af06f
parentMerge branch 'release/v0.2.0' (diff)
parentBump VERSION (diff)
downloadvim-cursorline-current-b48b57b35899796bfbea9a3aab8c584d8eaebfd5.tar.gz
vim-cursorline-current-b48b57b35899796bfbea9a3aab8c584d8eaebfd5.zip
Merge branch 'release/v0.3.0'v0.3.0
* release/v0.3.0: Call restore function on BufEnter Simplify suspend/restore funcs considerably
-rw-r--r--VERSION2
-rw-r--r--plugin/cursorline_current.vim23
2 files changed, 9 insertions, 16 deletions
diff --git a/VERSION b/VERSION
index 0ea3a94..0d91a54 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.2.0
+0.3.0
diff --git a/plugin/cursorline_current.vim b/plugin/cursorline_current.vim
index 828c581..43bf882 100644
--- a/plugin/cursorline_current.vim
+++ b/plugin/cursorline_current.vim
@@ -16,23 +16,14 @@ let g:loaded_cursorline_current = 1
" Suspend 'cursorline' when a window is inactive or inserting
function! s:Suspend() abort
- let w:cursorline_current_cache = &l:cursorline
- setlocal nocursorline
+ let w:cursorline_current = &l:cursorline
+ let &l:cursorline = 0
endfunction
" Restore 'cursorline' when a window is active and non-insert
function! s:Restore() abort
-
- " If we don't have a value for 'cursorline' from a previous s:Suspend(), use
- " the global value as the default
- if !exists('w:cursorline_current_cache')
- let w:cursorline_current_cache = &g:cursorline
- endif
-
- " Restore local value to the cached value and clear it
- let &l:cursorline = w:cursorline_current_cache
- unlet w:cursorline_current_cache
-
+ let &l:cursorline = get(w:, 'cursorline_current', &g:cursorline)
+ let w:cursorline_current = &l:cursorline
endfunction
" Call s:Suspend() on all windows besides the current one
@@ -62,9 +53,11 @@ augroup cursorline_current
" Turn off 'cursorline' for other windows on load
autocmd VimEnter * call s:Load()
- " Turn off 'cursorline' when leaving a window or losing focus
+ " Turn off 'cursorline' when leaving a window or losing focus. We call the
+ " restore again on BufEnter to handle existent local buffer values for the
+ " option overwriting the window value (Vim bug?)
autocmd WinLeave,FocusLost * call s:Suspend()
- autocmd WinEnter,FocusGained * call s:Restore()
+ autocmd BufEnter,WinEnter,FocusGained * call s:Restore()
" Turn off 'cursorline' when in insert mode
" Check g:cursorline_current_insert, in case the user doesn't want it