From dba8a0705d95cda76d599bb7d09964d67741a5c5 Mon Sep 17 00:00:00 2001 From: Jacob Niehus Date: Fri, 16 Oct 2015 15:43:12 -0700 Subject: [PATCH] Fix diff sometimes opening in preview window If the previous window no longer exists when Gedit is called, the attempt to change windows with 'wincmd p' fails and 'wincmd w' should be used instead. --- plugin/fugitive.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index af4d088..d493938 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1336,8 +1336,10 @@ function! s:Edit(cmd,bang,...) abort if winnr('$') == 1 let tabs = (&go =~# 'e' || !has('gui_running')) && &stal && (tabpagenr('$') >= &stal) execute 'rightbelow' (&lines - &previewheight - &cmdheight - tabs - 1 - !!&laststatus).'new' - else + elseif winnr('#') wincmd p + else + wincmd w endif if &diff let mywinnr = winnr()