Add support for :tab Gcommit
References https://github.com/tpope/vim-fugitive/issues/1011
This commit is contained in:
parent
409b098c93
commit
3ac95c4dde
@ -1064,9 +1064,10 @@ endfunction
|
|||||||
|
|
||||||
" Section: Gcommit
|
" Section: Gcommit
|
||||||
|
|
||||||
call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit(<q-args>)")
|
call s:command("-nargs=? -complete=customlist,s:CommitComplete Gcommit :execute s:Commit('<mods>', <q-args>)")
|
||||||
|
|
||||||
function! s:Commit(args, ...) abort
|
function! s:Commit(mods, args, ...) abort
|
||||||
|
let mods = s:gsub(a:mods ==# '<mods>' ? '' : a:mods, '<tab>', '-tab')
|
||||||
let repo = a:0 ? a:1 : s:repo()
|
let repo = a:0 ? a:1 : s:repo()
|
||||||
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
let cd = exists('*haslocaldir') && haslocaldir() ? 'lcd' : 'cd'
|
||||||
let dir = getcwd()
|
let dir = getcwd()
|
||||||
@ -1119,15 +1120,15 @@ function! s:Commit(args, ...) abort
|
|||||||
let args = '--cleanup=strip '.args
|
let args = '--cleanup=strip '.args
|
||||||
endif
|
endif
|
||||||
if bufname('%') == '' && line('$') == 1 && getline(1) == '' && !&mod
|
if bufname('%') == '' && line('$') == 1 && getline(1) == '' && !&mod
|
||||||
execute 'keepalt edit '.s:fnameescape(msgfile)
|
execute mods 'keepalt edit' s:fnameescape(msgfile)
|
||||||
elseif a:args =~# '\%(^\| \)-\%(-verbose\|\w*v\)\>'
|
elseif a:args =~# '\%(^\| \)-\%(-verbose\|\w*v\)\>' || mods =~# '\<tab\>'
|
||||||
execute 'keepalt -tabedit '.s:fnameescape(msgfile)
|
execute mods 'keepalt -tabedit' s:fnameescape(msgfile)
|
||||||
elseif s:buffer().type() ==# 'index'
|
elseif s:buffer().type() ==# 'index'
|
||||||
execute 'keepalt edit '.s:fnameescape(msgfile)
|
execute mods 'keepalt edit' s:fnameescape(msgfile)
|
||||||
execute (search('^#','n')+1).'wincmd+'
|
execute (search('^#','n')+1).'wincmd+'
|
||||||
setlocal nopreviewwindow
|
setlocal nopreviewwindow
|
||||||
else
|
else
|
||||||
execute 'keepalt split '.s:fnameescape(msgfile)
|
execute mods 'keepalt split' s:fnameescape(msgfile)
|
||||||
endif
|
endif
|
||||||
let b:fugitive_commit_arguments = args
|
let b:fugitive_commit_arguments = args
|
||||||
setlocal bufhidden=wipe filetype=gitcommit
|
setlocal bufhidden=wipe filetype=gitcommit
|
||||||
@ -1163,7 +1164,7 @@ function! s:FinishCommit() abort
|
|||||||
let args = getbufvar(+expand('<abuf>'),'fugitive_commit_arguments')
|
let args = getbufvar(+expand('<abuf>'),'fugitive_commit_arguments')
|
||||||
if !empty(args)
|
if !empty(args)
|
||||||
call setbufvar(+expand('<abuf>'),'fugitive_commit_arguments','')
|
call setbufvar(+expand('<abuf>'),'fugitive_commit_arguments','')
|
||||||
return s:Commit(args, s:repo(getbufvar(+expand('<abuf>'),'git_dir')))
|
return s:Commit('', args, s:repo(getbufvar(+expand('<abuf>'),'git_dir')))
|
||||||
endif
|
endif
|
||||||
return ''
|
return ''
|
||||||
endfunction
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user