Add s:initialize_job()

This commit is contained in:
Marco Hinz 2017-01-18 13:40:34 +01:00
parent 3aa8eb9ec6
commit b839e8092f
No known key found for this signature in database
GPG Key ID: 1C980A1B657B4A4F

View File

@ -48,20 +48,11 @@ endfunction
function! sy#repo#get_diff_start(vcs, do_register) abort
call sy#verbose('s:get_diff_start()', a:vcs)
let options = {
\ 'stdoutbuf': [],
\ 'vcs': a:vcs,
\ 'do_register': a:do_register,
\ 'winid': win_getid(),
\ }
let cmd = s:expand_cmd(a:vcs)
let cmd = (has('win32') && &shell =~ 'cmd') ? cmd : ['sh', '-c', cmd]
if has('nvim')
if exists('b:job_id_'.a:vcs)
silent! call jobstop(b:job_id_{a:vcs})
endif
let [cmd, options] = s:initialize_job(a:vcs, a:do_register)
execute b:sy_info.chdir fnameescape(b:sy_info.dir)
try
let b:job_id_{a:vcs} = jobstart(cmd, extend(options, {
@ -76,6 +67,7 @@ function! sy#repo#get_diff_start(vcs, do_register) abort
if exists('b:job_id_'.a:vcs)
silent! call job_stop(b:job_id_{a:vcs})
endif
let [cmd, options] = s:initialize_job(a:vcs, a:do_register)
execute b:sy_info.chdir fnameescape(b:sy_info.dir)
try
let b:job_id_{a:vcs} = job_start(cmd, {
@ -219,6 +211,19 @@ function! sy#repo#debug_detection()
endfor
endfunction
" Function: s:initialize_job {{{1
function! s:initialize_job(vcs, do_register) abort
let cmd = s:expand_cmd(a:vcs)
let cmd = (has('win32') && &shell =~ 'cmd') ? cmd : ['sh', '-c', cmd]
let options = {
\ 'stdoutbuf': [],
\ 'vcs': a:vcs,
\ 'do_register': a:do_register,
\ 'winid': win_getid(),
\ }
return [cmd, options]
endfunction
" Function: s:get_vcs_path {{{1
function! s:get_vcs_path(vcs) abort
return (a:vcs =~# '\v(git|cvs|accurev|tfs)') ? b:sy_info.file : b:sy_info.path