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
This commit is contained in:
Tim Pope
2021-12-28 15:56:58 -05:00
parent 831fdab983
commit ee992c808c

View File

@@ -256,13 +256,15 @@ function! fugitive#Autowrite() abort
endfunction endfunction
function! fugitive#Wait(job_or_jobs, ...) abort function! fugitive#Wait(job_or_jobs, ...) abort
let jobs = type(a:job_or_jobs) == type([]) ? copy(a:job_or_jobs) : [a:job_or_jobs] let original = 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 jobs = map(copy(original), 'type(v:val) ==# type({}) ? get(v:val, "job", "") : v:val')
call filter(jobs, 'type(v:val) !=# type("")') call filter(jobs, 'type(v:val) !=# type("")')
let timeout_ms = a:0 ? a:1 : -1 let timeout_ms = a:0 ? a:1 : -1
if exists('*jobwait') if exists('*jobwait')
call map(copy(jobs), 'chanclose(v:val, "stdin")') call map(copy(jobs), 'chanclose(v:val, "stdin")')
call jobwait(jobs, timeout_ms) 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) if len(jobs)
sleep 1m sleep 1m
endif endif