mirror of
https://github.com/airblade/vim-gitgutter.git
synced 2025-11-08 11:33:48 -05:00
Keep references to pending jobs to avoid premature deletion
This only applies to Vim. See #735.
This commit is contained in:
@@ -6,6 +6,8 @@ let s:available = has('nvim') || (
|
|||||||
\ )
|
\ )
|
||||||
\ )
|
\ )
|
||||||
|
|
||||||
|
let s:jobs = {}
|
||||||
|
|
||||||
function! gitgutter#async#available()
|
function! gitgutter#async#available()
|
||||||
return s:available
|
return s:available
|
||||||
endfunction
|
endfunction
|
||||||
@@ -28,11 +30,12 @@ function! gitgutter#async#execute(cmd, bufnr, handler) abort
|
|||||||
\ 'on_exit': function('s:on_exit_nvim')
|
\ 'on_exit': function('s:on_exit_nvim')
|
||||||
\ }))
|
\ }))
|
||||||
else
|
else
|
||||||
call job_start(command, {
|
let job = job_start(command, {
|
||||||
\ 'out_cb': function('s:on_stdout_vim', options),
|
\ 'out_cb': function('s:on_stdout_vim', options),
|
||||||
\ 'err_cb': function('s:on_stderr_vim', options),
|
\ 'err_cb': function('s:on_stderr_vim', options),
|
||||||
\ 'close_cb': function('s:on_exit_vim', options)
|
\ 'close_cb': function('s:on_exit_vim', options)
|
||||||
\ })
|
\ })
|
||||||
|
let s:jobs[s:job_id(job)] = 1
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -83,6 +86,8 @@ endfunction
|
|||||||
|
|
||||||
function! s:on_exit_vim(channel) dict abort
|
function! s:on_exit_vim(channel) dict abort
|
||||||
let job = ch_getjob(a:channel)
|
let job = ch_getjob(a:channel)
|
||||||
|
let jobid = s:job_id(job)
|
||||||
|
if has_key(s:jobs, jobid) | unlet s:jobs[jobid] | endif
|
||||||
while 1
|
while 1
|
||||||
if job_status(job) == 'dead'
|
if job_status(job) == 'dead'
|
||||||
let exit_code = job_info(job).exitval
|
let exit_code = job_info(job).exitval
|
||||||
@@ -95,3 +100,8 @@ function! s:on_exit_vim(channel) dict abort
|
|||||||
call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
|
call self.handler.out(self.buffer, join(self.stdoutbuffer, "\n"))
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:job_id(job)
|
||||||
|
" Vim
|
||||||
|
return job_info(a:job).process
|
||||||
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user