1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-14 23:49:19 +08:00

Fix Git mv options (#4353)

This commit is contained in:
Wang Shidong 2021-08-04 18:47:16 +08:00 committed by GitHub
parent 95e235ab43
commit 41c981e9c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,35 +12,57 @@ let s:JOB = SpaceVim#api#import('job')
function! git#mv#run(args) abort function! git#mv#run(args) abort
let args = a:args let args = a:args
if index(a:args, '%') !=# -1 if index(a:args, '%') !=# -1
let index = index(a:args, '%') let index = index(a:args, '%')
let args[index] = expand('%') let args[index] = expand('%')
endif endif
let cmd = ['git', 'mv'] + args let cmd = ['git', 'mv'] + args
call git#logger#info('git-mv cmd:' . string(cmd)) call git#logger#info('git-mv cmd:' . string(cmd))
call s:JOB.start(cmd, call s:JOB.start(cmd,
\ { \ {
\ 'on_exit' : function('s:on_exit'), \ 'on_exit' : function('s:on_exit'),
\ } \ }
\ ) \ )
endfunction endfunction
function! s:on_exit(id, data, event) abort function! s:on_exit(id, data, event) abort
call git#logger#info('git-mv exit data:' . string(a:data)) call git#logger#info('git-mv exit data:' . string(a:data))
if a:data ==# 0 if a:data ==# 0
if exists(':GitGutter') if exists(':GitGutter')
GitGutter GitGutter
endif
echo 'done!'
else
echo 'failed!'
endif endif
echo 'done!'
else
echo 'failed!'
endif
endfunction endfunction
function! git#rm#complete(ArgLead, CmdLine, CursorPos) abort function! s:options() abort
return join([
\ '-v',
\ '-n',
\ '-f',
\ '-k',
\ ], "\n")
endfunction
return "%\n" . join(getcompletion(a:ArgLead, 'file'), "\n") function! s:long_options() abort
return join([
\ '--verbose',
\ '--dry-run',
\ '--force',
\ ], "\n")
endfunction
function! git#mv#complete(ArgLead, CmdLine, CursorPos) abort
if a:ArgLead =~# '^--'
return s:long_options()
elseif a:ArgLead =~# '^-'
return s:options()
endif
return "%\n" . join(getcompletion(a:ArgLead, 'file'), "\n")
endfunction endfunction