Allow close callback to run before leaving job wait loop

Apparently, both job_status() == "dead" and ch_status() == "closed"
isn't enough to guarantee all callbacks have run.  One last sleep seems
to do the trick, but let's also add a sanity check because this can
cause confusing, hard to debug behavior.
This commit is contained in:
Tim Pope
2021-03-27 23:04:13 -04:00
parent 00cb68e627
commit f7321f6d5b

View File

@@ -2501,9 +2501,10 @@ endfunction
function! s:RunTick(job) abort function! s:RunTick(job) abort
if type(a:job) == v:t_number if type(a:job) == v:t_number
return jobwait([a:job], 1)[0] == -1 return jobwait([a:job], 1)[0] == -1
elseif type(a:job) == v:t_job && (ch_status(a:job) !=# 'closed' || job_status(a:job) ==# 'run') elseif type(a:job) == 8
let running = ch_status(a:job) !=# 'closed' || job_status(a:job) ==# 'run'
sleep 1m sleep 1m
return ch_status(a:job) !=# 'closed' || job_status(a:job) ==# 'run' return running
endif endif
endfunction endfunction
@@ -2536,6 +2537,9 @@ function! s:RunWait(state, tmp, job) abort
endif endif
endif endif
endwhile endwhile
if !has_key(a:state, 'request') && has_key(a:state, 'job') && exists('*job_status') && job_status(a:job) ==# "dead"
throw 'fugitive: close callback did not fire; this should never happen'
endif
call s:RunEcho(a:tmp) call s:RunEcho(a:tmp)
echo echo
call s:RunEdit(a:state, a:tmp, a:job) call s:RunEdit(a:state, a:tmp, a:job)