mirror of
https://github.com/junegunn/vim-plug.git
synced 2024-12-19 10:35:38 -07:00
Address out-of-order invocation of out_cb and exit_cb
This commit is contained in:
parent
b94607b172
commit
d1022e948e
36
plug.vim
36
plug.vim
@ -1121,36 +1121,28 @@ function! s:job_out_cb(self, data) abort
|
|||||||
endif
|
endif
|
||||||
" To reduce the number of buffer updates
|
" To reduce the number of buffer updates
|
||||||
let self.tick = get(self, 'tick', -1) + 1
|
let self.tick = get(self, 'tick', -1) + 1
|
||||||
if self.tick % len(s:jobs) == 0
|
if !self.running || self.tick % len(s:jobs) == 0
|
||||||
call s:log(self.new ? '+' : '*', self.name, self.result)
|
let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-')
|
||||||
|
call s:log(bullet, self.name, self.result)
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:job_exit_cb(self, data) abort
|
function! s:job_exit_cb(self, data) abort
|
||||||
let self = a:self
|
let a:self.running = 0
|
||||||
call s:reap(self.name)
|
let a:self.error = a:data != 0
|
||||||
|
call s:reap(a:self.name)
|
||||||
call s:tick()
|
call s:tick()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:vim8_cb(fn, job, ch, data)
|
function! s:job_cb(fn, job, ch, data)
|
||||||
if !s:plug_window_exists() " plug window closed
|
if !s:plug_window_exists() " plug window closed
|
||||||
return s:job_abort()
|
return s:job_abort()
|
||||||
endif
|
endif
|
||||||
call call(a:fn, [a:job, split(a:data, '[\r\n]', 1)])
|
call call(a:fn, [a:job, a:data])
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" When a:event == 'stdout', data = list of strings
|
function! s:nvim_cb(job_id, data, event) abort
|
||||||
" When a:event == 'exit', data = returncode
|
call s:job_cb(a:event == 'stdout' ? 's:job_out_cb' : 's:job_exit_cb', self, 0, a:data)
|
||||||
function! s:nvim_job_handler(job_id, data, event) abort
|
|
||||||
if !s:plug_window_exists() " plug window closed
|
|
||||||
return s:job_abort()
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:event == 'stdout'
|
|
||||||
call s:job_out_cb(self, a:data)
|
|
||||||
elseif a:event == 'exit'
|
|
||||||
call s:job_exit_cb(self, a:data)
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:spawn(name, cmd, opts)
|
function! s:spawn(name, cmd, opts)
|
||||||
@ -1162,8 +1154,8 @@ function! s:spawn(name, cmd, opts)
|
|||||||
|
|
||||||
if s:nvim
|
if s:nvim
|
||||||
call extend(job, {
|
call extend(job, {
|
||||||
\ 'on_stdout': function('s:nvim_job_handler'),
|
\ 'on_stdout': function('s:nvim_cb'),
|
||||||
\ 'on_exit': function('s:nvim_job_handler'),
|
\ 'on_exit': function('s:nvim_cb'),
|
||||||
\ })
|
\ })
|
||||||
let jid = jobstart(argv, job)
|
let jid = jobstart(argv, job)
|
||||||
if jid > 0
|
if jid > 0
|
||||||
@ -1176,8 +1168,8 @@ function! s:spawn(name, cmd, opts)
|
|||||||
endif
|
endif
|
||||||
elseif s:vim8
|
elseif s:vim8
|
||||||
let jid = job_start(argv, {
|
let jid = job_start(argv, {
|
||||||
\ 'callback': function('s:vim8_cb', ['s:job_out_cb', job]),
|
\ 'out_cb': { c, d -> s:job_cb('s:job_out_cb', job, c, split(d, '[\r\n]', 1)) },
|
||||||
\ 'exit_cb': function('s:vim8_cb', ['s:job_exit_cb', job]),
|
\ 'exit_cb': { c, d -> s:job_cb('s:job_exit_cb', job, c, d) },
|
||||||
\ 'out_mode': 'raw'
|
\ 'out_mode': 'raw'
|
||||||
\})
|
\})
|
||||||
if job_status(jid) == 'run'
|
if job_status(jid) == 'run'
|
||||||
|
Loading…
Reference in New Issue
Block a user