From 9e8c040bcb01391aa8ef7bb3206eed156c9315bc Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 7 Mar 2018 20:30:29 +0100 Subject: git-blamer: Fix bug causing `cursorbind` to be set on other windows In some instances with more than one window open, closing the GitBlamer window would cause other windows in the tab to have `cursorbind` (and presumably `scrollbind`) set. Fix the bug by setting `scrollbind` and `cursorbind` on the buffer (these are window-local variables, we'll have to find out if it's weird to set them on a buffer), and store the "restore" command in a buffer-local variable (local to the GitBlamer window). --- bundle/git-blamer/autoload/git_blamer.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bundle/git-blamer/autoload/git_blamer.vim') diff --git a/bundle/git-blamer/autoload/git_blamer.vim b/bundle/git-blamer/autoload/git_blamer.vim index 65a1c24..83efe4c 100644 --- a/bundle/git-blamer/autoload/git_blamer.vim +++ b/bundle/git-blamer/autoload/git_blamer.vim @@ -5,17 +5,18 @@ function! git_blamer#Blame() let l:line_number = line('.') let l:buffer_name = shellescape(bufname('%')) - let l:window_number = winnr() + let l:buffer_number = bufnr('%') setlocal scrollbind cursorbind - let t:git_blamer_restore = 'call setwinvar(' . l:window_number . ', "&scrollbind", 0) | - \ call setwinvar(' . l:window_number . ', "&cursorbind", 0)' " Open new window leftabove vnew setlocal noswapfile nowrap nolist nobuflisted buftype=nofile bufhidden=wipe setlocal scrollbind cursorbind + let b:git_blamer_restore = 'call setbufvar(' . l:buffer_number . ', "&scrollbind", 0) | + \ call setbufvar(' . l:buffer_number . ', "&cursorbind", 0)' + " Read in `git blame` output execute 'read !git blame -w ' . l:buffer_name @@ -28,5 +29,5 @@ function! git_blamer#Blame() call setpos('.', [0, l:line_number, 0, 0]) " Restore starting file's scrollbind on exit - autocmd BufWinLeave execute t:git_blamer_restore + autocmd BufWinLeave execute b:git_blamer_restore endfunction -- cgit v1.2.3