diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2018-09-09 13:58:09 +1200 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2018-09-09 13:58:09 +1200 |
commit | b48b57b35899796bfbea9a3aab8c584d8eaebfd5 (patch) | |
tree | dea8feef64974d9f74861b59c68128924d9af06f | |
parent | Merge branch 'release/v0.2.0' (diff) | |
parent | Bump VERSION (diff) | |
download | vim-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-- | VERSION | 2 | ||||
-rw-r--r-- | plugin/cursorline_current.vim | 23 |
2 files changed, 9 insertions, 16 deletions
@@ -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 |