Implement :Gwq
This commit is contained in:
parent
3933bfdc57
commit
2e4c9236d6
@ -118,6 +118,13 @@ that are part of Git repositories).
|
||||
:0:foo.txt or even :0 to write to just that stage in
|
||||
the index.
|
||||
|
||||
*fugitive-:Gwq*
|
||||
:Gwq [path] Like |:Gwrite| followed by |:quit| if the write
|
||||
succeeded.
|
||||
|
||||
:Gwq! [path] Like |:Gwrite|! followed by |:quit|! if the write
|
||||
succeeded.
|
||||
|
||||
*fugitive-:Gdiff*
|
||||
:Gdiff [revision] Perform a |vimdiff| against the current file in the
|
||||
given revision. With no argument, the version in the
|
||||
|
@ -903,6 +903,8 @@ call s:command("-bar -bang -nargs=? -count -complete=customlist,s:EditComplete G
|
||||
" Gwrite, Gwq {{{1
|
||||
|
||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwrite :execute s:Write(<bang>0,<f-args>)")
|
||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gw :execute s:Write(<bang>0,<f-args>)")
|
||||
call s:command("-bar -bang -nargs=? -complete=customlist,s:EditComplete Gwq :execute s:Wq(<bang>0,<f-args>)")
|
||||
|
||||
function! s:Write(force,...) abort
|
||||
if exists('b:fugitive_commit_arguments')
|
||||
@ -1022,6 +1024,19 @@ function! s:Write(force,...) abort
|
||||
return 'checktime'
|
||||
endfunction
|
||||
|
||||
function! s:Wq(force,...) abort
|
||||
let bang = a:force ? '!' : ''
|
||||
if exists('b:fugitive_commit_arguments')
|
||||
return 'wq'.bang
|
||||
endif
|
||||
let result = call(s:function('s:Write'),[a:force]+a:000)
|
||||
if result =~# '^\%(write\|wq\|echoerr\)'
|
||||
return s:sub(result,'^write','wq')
|
||||
else
|
||||
return result.'|quit'.bang
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
" Gdiff {{{1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user