From be42215003c4955eae8f72fa14af7a371b6088e3 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Sat, 1 Oct 2011 16:48:39 -0400 Subject: [PATCH] Enter on a +/- diff line jumps to that line This is useful particularly in conjunction with :Gblame. Press `i` on a line in a blame to open the commit. If the diff reveals a new point of interest, press enter on that line to jump to it in the history, then :Gblame again. --- plugin/fugitive.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index c776502..fb4dcaf 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -2177,6 +2177,21 @@ function! s:GF(mode) abort elseif getline('.') =~# '^[+-]\{3\} [ab/]' let ref = getline('.')[4:] + elseif getline('.') =~# '^[+-]' && search('^@@ -\d\+,\d\+ +\d\+,','bnW') + let type = getline('.')[0] + let lnum = line('.') - 1 + let offset = -1 + while getline(lnum) !~# '^@@ -\d\+,\d\+ +\d\+,' + if getline(lnum) =~# '^[ '.type.']' + let offset += 1 + endif + let lnum -= 1 + endwhile + let offset += matchstr(getline(lnum), type.'\zs\d\+') + let ref = getline(search('^'.type.'\{3\} [ab]/','bnW'))[4:-1] + let dcmd = '+'.offset.'|foldopen' + let dref = '' + elseif getline('.') =~# '^rename from ' let ref = 'a/'.getline('.')[12:] elseif getline('.') =~# '^rename to '