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).
This commit is contained in:
Omar Sandoval
2019-10-19 01:35:30 -07:00
committed by Tim Pope
parent a2d76c4583
commit 3936a74584

View File

@@ -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('')