From c8070aec7e66772322f968a748af757938931b20 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 7 Apr 2014 03:52:31 -0400 Subject: [PATCH] Ridiculous hack to set cursor position on :Gdiff References #429. --- plugin/fugitive.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index bdc9de1..ee675aa 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1513,6 +1513,9 @@ function! s:Diff(bang,...) abort let spec = s:repo().translate(file) let commit = matchstr(spec,'\C[^:/]//\zs\x\+') let restore = s:diff_restore() + if exists('+cursorbind') + set cursorbind + endif let w:fugitive_diff_restore = restore if s:buffer().compare_age(commit) < 0 execute 'rightbelow '.vert.'diffsplit '.s:fnameescape(spec) @@ -1520,6 +1523,11 @@ function! s:Diff(bang,...) abort execute 'leftabove '.vert.'diffsplit '.s:fnameescape(spec) endif let w:fugitive_diff_restore = restore + let winnr = winnr() + if getwinvar('#', '&diff') + wincmd p + call feedkeys("\p", 'n') + endif return '' catch /^fugitive:/ return 'echoerr v:errmsg'