Vim: use close_cb to trigger exit_cb

Before Vim 8.0.50, an exited job was only detected with a potentially huge
delay.

Thus, for versions smaller than 8.0.50, we add a close_cb callback that runs
job_status() which in return runs the exit_cb callback immeditely if the job was
found to be dead.

Vim patch:

    01688ad545

References: #216.
This commit is contained in:
Marco Hinz 2017-02-16 13:54:54 +01:00
parent 45a28549bd
commit 6364e8f7f2
2 changed files with 15 additions and 3 deletions

View File

@ -36,6 +36,14 @@ function! s:callback_stdout_vim(_job_id, data) dict abort
let self.stdoutbuf += [a:data] let self.stdoutbuf += [a:data]
endfunction endfunction
" Function: s:callback_close {{{1
function! s:callback_close(channel) dict abort
try
silent! call job_status(ch_getjob(a:channel))
catch
endtry
endfunction
" Function: s:callback_exit {{{1 " Function: s:callback_exit {{{1
function! s:callback_exit(_job_id, exitval, ...) dict abort function! s:callback_exit(_job_id, exitval, ...) dict abort
call sy#verbose('callback_exit()', self.vcs) call sy#verbose('callback_exit()', self.vcs)
@ -83,11 +91,15 @@ function! sy#repo#get_diff_start(vcs, do_register) abort
try try
execute chdir fnameescape(b:sy_info.dir) execute chdir fnameescape(b:sy_info.dir)
let b:sy_job_id_{a:vcs} = job_start(cmd, { let opts = {
\ 'in_io': 'null', \ 'in_io': 'null',
\ 'out_cb': function('s:callback_stdout_vim', options), \ 'out_cb': function('s:callback_stdout_vim', options),
\ 'exit_cb': function('s:callback_exit', options), \ 'exit_cb': function('s:callback_exit', options),
\ }) \ }
if !has('patch-8.0.50')
let opts.close_cb = function('s:callback_close')
endif
let b:sy_job_id_{a:vcs} = job_start(cmd, opts)
finally finally
execute chdir fnameescape(cwd) execute chdir fnameescape(cwd)
endtry endtry

View File

@ -567,7 +567,7 @@ The plugin is slow!~
Line highlighting without showing signs?~ Line highlighting without showing signs?~
The line highlighting relies on signs being placed. The sign column is being The line highlighting relies on signs being placed. The sign column is being
shown automatically when there are placed signs. shown automatically if there are placed signs.
With a recent Vim, you can change that behaviour using 'signcolumn'. With a recent Vim, you can change that behaviour using 'signcolumn'.