From ee992c808c73353fe841d3bc6685efa8a2547067 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Tue, 28 Dec 2021 15:56:58 -0500 Subject: [PATCH] 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 --- autoload/fugitive.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index 7cac28d..40b12bd 100644 --- 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