From b8a6fd204c6fffad573439b6200aadf0d256a730 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 8 Jan 2019 20:23:04 -0500 Subject: [PATCH] Always default to horizontal split for :Gstatus Closes https://github.com/tpope/vim-fugitive/issues/1163 --- autoload/fugitive.vim | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 62978d9..e8fc906 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1894,29 +1894,27 @@ augroup END function! s:Status(bang, count, mods) abort try - let dir = b:git_dir - let mods = a:mods ==# '' || empty(a:mods) ? 'leftabove' : a:mods + let mods = a:mods ==# '' ? '' : a:mods + if mods !~# 'aboveleft|belowright\|leftabove\|rightbelow\|topleft\|botright' + let mods = 'topleft ' . mods + endif let file = fugitive#Find(':') + let arg = '+setl\ foldmethod=syntax\ foldlevel=1\|let\ w:fugitive_status=FugitiveGitDir() :' for winnr in range(1, winnr('$')) if s:cpath(file, fnamemodify(bufname(winbufnr(winnr)), ':p')) exe winnr . 'wincmd w' - let w:fugitive_status = dir + let w:fugitive_status = FugitiveGitDir() return s:ReloadStatus() endif endfor - let wide = winwidth(0) >= 160 if a:count ==# 0 - exe mods 'Gedit :' + exe mods 'Gedit' . (a:bang ? '!' : '') arg elseif a:bang - exe mods (a:count ==# -1 && wide ? 'vert' : '') 'Gpedit :' + exe mods 'Gpedit' arg wincmd P - elseif a:count ==# -1 && wide - exe mods 'Gvsplit :' else - exe mods a:count > 0 ? a:count : '' 'Gsplit :' + exe mods a:count > 0 ? a:count : '' 'Gsplit' arg endif - let w:fugitive_status = dir - setlocal foldmethod=syntax foldlevel=1 catch /^fugitive:/ return 'echoerr v:errmsg' endtry @@ -2862,7 +2860,7 @@ endfunction function! s:UsableWin(nr) abort return a:nr && !getwinvar(a:nr, '&previewwindow') && - \ empty(getwinvar(a:nr, 'fugitive_status')) && + \ (empty(getwinvar(a:nr, 'fugitive_status')) || getwinvar(a:nr, 'fugitive_type') !=# 'index') && \ index(['gitrebase', 'gitcommit'], getbufvar(winbufnr(a:nr), '&filetype')) < 0 && \ index(['nofile','help','quickfix'], getbufvar(winbufnr(a:nr), '&buftype')) < 0 endfunction @@ -2891,8 +2889,7 @@ function! s:BlurStatus() abort if len(winnrs) exe winnrs[0].'wincmd w' else - let wide = winwidth(0) >= 160 - exe 'rightbelow' (winwidth(0) >= 160 ? 'vert' : '') 'new' + belowright new endif if &diff let mywinnr = winnr()