From 3936a74584b4a5bfae99630dffe3d7024011b9e9 Mon Sep 17 00:00:00 2001 From: Omar Sandoval Date: Sat, 19 Oct 2019 01:35:30 -0700 Subject: [PATCH] Reset scrollbind/cursorbind after reblaming The following sequence of commands leaves the buffer with scrollbind and cursorbind set: :Gblame Reblame with one of -, ~, or P Quit with gq What's happening here is: 1. In BlameSubcommand, we set scrollbind and cursorbind on the buffer. We also set w:fugitive_leave on the blame buffer to reset scrollbind and cursorbind when the blame buffer is closed. 2. In BlameJump, we execute Gedit, which changes the window to a new buffer. Then, we delete the blame buffer, at which point we try to reset scrollbind and cursorbind. However, the original buffer isn't on a window anymore, so this doesn't do anything. 3. In BlameQuit, we go back to the original buffer. Note this snippet from `:help local-options`: "if this buffer has been edited in this window, the [option] values from back then are used". When the original buffer was last used, scrollbind and cursorbind were still set. Therefore, the buffer ends up with scrollbind and cursorbind set after leaving Gblame. The fix is to delete the blame buffer _before_ changing to the new buffer in BlameJump. This ensures that we restore the options while the original buffer is still around (which is how BlameQuit does it, too). --- autoload/fugitive.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 1f55249..67c8647 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -5130,12 +5130,10 @@ function! s:BlameJump(suffix, ...) abort let winnr = bufwinnr(blame_bufnr) if winnr > 0 exe winnr.'wincmd w' + exe bufnr.'bdelete' endif execute 'Gedit' s:fnameescape(commit . suffix . ':' . path) execute lnum - if winnr > 0 - exe bufnr.'bdelete' - endif endif if exists(':Gblame') let my_bufnr = bufnr('')