From 3ac95c4dde854d259147dfc8e008e3ca1db57a28 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 6 Apr 2018 14:52:53 -0400 Subject: [PATCH] Add support for :tab Gcommit References https://github.com/tpope/vim-fugitive/issues/1011 --- plugin/fugitive.vim | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 895136e..ca6d432 100644 --- a/plugin/fugitive.vim +++ b/plugin/fugitive.vim @@ -1064,9 +1064,10 @@ endfunction " Section: Gcommit -call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit()") +call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit('', )") -function! s:Commit(args, ...) abort +function! s:Commit(mods, args, ...) abort + let mods = s:gsub(a:mods ==# '' ? '' : a:mods, '', '-tab') let repo = a:0 ? a:1 : s:repo() let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd' let dir = getcwd() @@ -1119,15 +1120,15 @@ function! s:Commit(args, ...) abort let args = '--cleanup=strip '.args endif if bufname('%') == '' && line('$') == 1 && getline(1) == '' && !&mod - execute 'keepalt edit '.s:fnameescape(msgfile) - elseif a:args =~# '\%(^\| \)-\%(-verbose\|\w*v\)\>' - execute 'keepalt -tabedit '.s:fnameescape(msgfile) + execute mods 'keepalt edit' s:fnameescape(msgfile) + elseif a:args =~# '\%(^\| \)-\%(-verbose\|\w*v\)\>' || mods =~# '\' + execute mods 'keepalt -tabedit' s:fnameescape(msgfile) elseif s:buffer().type() ==# 'index' - execute 'keepalt edit '.s:fnameescape(msgfile) + execute mods 'keepalt edit' s:fnameescape(msgfile) execute (search('^#','n')+1).'wincmd+' setlocal nopreviewwindow else - execute 'keepalt split '.s:fnameescape(msgfile) + execute mods 'keepalt split' s:fnameescape(msgfile) endif let b:fugitive_commit_arguments = args setlocal bufhidden=wipe filetype=gitcommit @@ -1163,7 +1164,7 @@ function! s:FinishCommit() abort let args = getbufvar(+expand(''),'fugitive_commit_arguments') if !empty(args) call setbufvar(+expand(''),'fugitive_commit_arguments','') - return s:Commit(args, s:repo(getbufvar(+expand(''),'git_dir'))) + return s:Commit('', args, s:repo(getbufvar(+expand(''),'git_dir'))) endif return '' endfunction