From dcbab18a35d471504260379f3919974747afc165 Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 5 Jun 2017 13:30:40 +0100 Subject: Stop errors being generated when jobs are removed from the Dictionary before callbacks fire --- autoload/ale/job.vim | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim index aeef5796..52789bb5 100644 --- a/autoload/ale/job.vim +++ b/autoload/ale/job.vim @@ -83,7 +83,7 @@ function! s:VimOutputCallback(channel, data) abort let l:job_id = ale#job#ParseVim8ProcessID(string(l:job)) " Only call the callbacks for jobs which are valid. - if l:job_id > 0 + if l:job_id > 0 && has_key(s:job_map, l:job_id) call ale#util#GetFunction(s:job_map[l:job_id].out_cb)(l:job_id, a:data) endif endfunction @@ -93,7 +93,7 @@ function! s:VimErrorCallback(channel, data) abort let l:job_id = ale#job#ParseVim8ProcessID(string(l:job)) " Only call the callbacks for jobs which are valid. - if l:job_id > 0 + if l:job_id > 0 && has_key(s:job_map, l:job_id) call ale#util#GetFunction(s:job_map[l:job_id].err_cb)(l:job_id, a:data) endif endfunction @@ -103,6 +103,10 @@ function! s:VimCloseCallback(channel) abort let l:job_id = ale#job#ParseVim8ProcessID(string(l:job)) let l:info = get(s:job_map, l:job_id, {}) + if empty(l:info) + return + endif + " job_status() can trigger the exit handler. " The channel can close before the job has exited. if job_status(l:job) ==# 'dead' @@ -122,6 +126,11 @@ endfunction function! s:VimExitCallback(job, exit_code) abort let l:job_id = ale#job#ParseVim8ProcessID(string(a:job)) let l:info = get(s:job_map, l:job_id, {}) + + if empty(l:info) + return + endif + let l:info.exit_code = a:exit_code " The program can exit before the data has finished being read. -- cgit v1.2.3