Skip to content

Commit 3936a74

Browse files
osandovtpope
authored andcommitted
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).
1 parent a2d76c4 commit 3936a74

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

autoload/fugitive.vim

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5130,12 +5130,10 @@ function! s:BlameJump(suffix, ...) abort
51305130
let winnr = bufwinnr(blame_bufnr)
51315131
if winnr > 0
51325132
exe winnr.'wincmd w'
5133+
exe bufnr.'bdelete'
51335134
endif
51345135
execute 'Gedit' s:fnameescape(commit . suffix . ':' . path)
51355136
execute lnum
5136-
if winnr > 0
5137-
exe bufnr.'bdelete'
5138-
endif
51395137
endif
51405138
if exists(':Gblame')
51415139
let my_bufnr = bufnr('')

0 commit comments

Comments
 (0)