commit ee992c808c73353fe841d3bc6685efa8a2547067 (tree)
parent 831fdab98385876a2cbdf841604d41ada3232510
Author: Tim Pope <code@tpope.net>
Date: Tue, 28 Dec 2021 15:56:58 -0500
Narrow application of broken jobwait() workaround
Neovim seemlingly forces a redraw if :sleep is called while defocused,
but only if at least one FocusGained/FocusLost autocommand is defined.
The purpose of this :sleep is to force the exit callback to run when
jobwait() erroneously refuses to do the job. Our exit callback removes
the job from the dictionary, so we can use the lack of a job key in any
dictionary as a signal that we can skip it. Hacks on top of hacks.
Resolves: https://github.com/tpope/vim-fugitive/issues/1909
References: https://github.com/tpope/vim-fugitive/issues/1857
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim
@@ -256,13 +256,15 @@ function! fugitive#Autowrite() abort
endfunction
function! fugitive#Wait(job_or_jobs, ...) abort
- let jobs = type(a:job_or_jobs) == type([]) ? copy(a:job_or_jobs) : [a:job_or_jobs]
- call map(jobs, 'type(v:val) ==# type({}) ? get(v:val, "job", "") : v:val')
+ let original = type(a:job_or_jobs) == type([]) ? copy(a:job_or_jobs) : [a:job_or_jobs]
+ let jobs = map(copy(original), 'type(v:val) ==# type({}) ? get(v:val, "job", "") : v:val')
call filter(jobs, 'type(v:val) !=# type("")')
let timeout_ms = a:0 ? a:1 : -1
if exists('*jobwait')
call map(copy(jobs), 'chanclose(v:val, "stdin")')
call jobwait(jobs, timeout_ms)
+ let jobs = map(copy(original), 'type(v:val) ==# type({}) ? get(v:val, "job", "") : v:val')
+ call filter(jobs, 'type(v:val) !=# type("")')
if len(jobs)
sleep 1m
endif