From 16bfd4fa92020c1684342aefa6a5665a16c4aebd Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 13 Aug 2019 17:20:00 -0400 Subject: [PATCH] Fix offset jumping to patch on :Gblame --reverse --- autoload/fugitive.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 203dfbd..6f07772 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -4837,6 +4837,7 @@ function! s:BlameCommit(cmd, ...) abort if commit =~# '^0*$' return 'echoerr ' . string('fugitive: no commit') endif + let sigil = has_key(a:0 ? a:2 : s:TempState(), 'blame_reverse_end') ? '-' : '+' let cmd = s:Open((s:BlameBufnr() < 0 ? '' : &splitbelow ? "botright " : "topleft ") . a:cmd, 0, '', commit, [commit]) if cmd =~# '^echoerr' return cmd @@ -4849,8 +4850,9 @@ function! s:BlameCommit(cmd, ...) abort call search('^+++') let head = line('.') while search('^@@ \|^diff ') && getline('.') =~# '^@@ ' - let top = +matchstr(getline('.'),' +\zs\d\+') - let len = +matchstr(getline('.'),' +\d\+,\zs\d\+') + let top = +matchstr(getline('.'),' ' . sigil .'\zs\d\+') + let len = +matchstr(getline('.'),' ' . sigil . '\d\+,\zs\d\+') + echo [sigil, top, len] if lnum >= top && lnum <= top + len let offset = lnum - top if &scrolloff @@ -4862,7 +4864,7 @@ function! s:BlameCommit(cmd, ...) abort endif while offset > 0 && line('.') < line('$') + - if getline('.') =~# '^[ +]' + if getline('.') =~# '^[ ' . sigil . ']' let offset -= 1 endif endwhile