commit f7321f6d5b3c6838b9cf05e8f3df3a275f2f528b (tree)
parent 00cb68e6270de570e3769447441b88ec25462050
Author: Tim Pope <code@tpope.net>
Date: Sat, 27 Mar 2021 23:04:13 -0400
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.
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -2501,9 +2501,10 @@ endfunction
function! s:RunTick(job) abort
if type(a:job) == v:t_number
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
- return ch_status(a:job) !=# 'closed' || job_status(a:job) ==# 'run'
+ return running
endif
endfunction
@@ -2536,6 +2537,9 @@ function! s:RunWait(state, tmp, job) abort
endif
endif
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)
echo
call s:RunEdit(a:state, a:tmp, a:job)