Fix missing progress update (#127)
In the recent versions of NeoVim, jobstart() does not return monotonically increasing numbers, this caused vim-plug to miss updating the progress of a task when the job ID for the task is already reassigned to a new task.
This commit is contained in:
parent
68ad02c5c3
commit
48514768c2
1 changed files with 8 additions and 12 deletions
20
plug.vim
20
plug.vim
|
@ -752,20 +752,18 @@ function! s:job_abort()
|
|||
call system('rm -rf ' . s:shellesc(g:plugs[name].dir))
|
||||
endif
|
||||
endfor
|
||||
let s:jobs = {}
|
||||
let s:jobs_idx = {}
|
||||
let s:jobs = {}
|
||||
endfunction
|
||||
|
||||
function! s:job_handler() abort
|
||||
function! s:job_handler(name) abort
|
||||
if !s:plug_window_exists() " plug window closed
|
||||
return s:job_abort()
|
||||
endif
|
||||
|
||||
let name = get(s:jobs_idx, v:job_data[0], '')
|
||||
if empty(name) " stale task
|
||||
if !has_key(s:jobs, a:name)
|
||||
return
|
||||
endif
|
||||
let job = s:jobs[name]
|
||||
let job = s:jobs[a:name]
|
||||
|
||||
if v:job_data[1] == 'exit'
|
||||
let job.running = 0
|
||||
|
@ -773,14 +771,14 @@ function! s:job_handler() abort
|
|||
let job.error = 1
|
||||
let job.result = substitute(job.result, "Error[\r\n]$", '', '')
|
||||
endif
|
||||
call s:reap(name)
|
||||
call s:reap(a:name)
|
||||
call s:tick()
|
||||
else
|
||||
let job.result .= s:to_s(v:job_data[2])
|
||||
" To reduce the number of buffer updates
|
||||
let job.tick = get(job, 'tick', -1) + 1
|
||||
if job.tick % len(s:jobs) == 0
|
||||
call s:log(job.new ? '+' : '*', name, job.result)
|
||||
call s:log(job.new ? '+' : '*', a:name, job.result)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
@ -795,10 +793,9 @@ function! s:spawn(name, cmd, opts)
|
|||
\ (has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir) : a:cmd)
|
||||
\ . ' || echo Error'])
|
||||
if x > 0
|
||||
let s:jobs_idx[x] = a:name
|
||||
let job.jobid = x
|
||||
augroup PlugJobControl
|
||||
execute 'autocmd JobActivity' a:name 'call s:job_handler()'
|
||||
execute 'autocmd JobActivity' a:name printf('call s:job_handler(%s)', string(a:name))
|
||||
augroup END
|
||||
else
|
||||
let job.running = 0
|
||||
|
@ -869,8 +866,7 @@ function! s:log(bullet, name, lines)
|
|||
endfunction
|
||||
|
||||
function! s:update_vim()
|
||||
let s:jobs = {}
|
||||
let s:jobs_idx = {}
|
||||
let s:jobs = {}
|
||||
|
||||
call s:bar()
|
||||
call s:tick()
|
||||
|
|
Loading…
Reference in a new issue