diff options
author | w0rp <devw0rp@gmail.com> | 2017-06-05 13:30:40 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-06-05 13:30:40 +0100 |
commit | dcbab18a35d471504260379f3919974747afc165 (patch) | |
tree | 1e4bb24e94f045d34ca0f2cffe0ec134a8c5f89c /autoload | |
parent | 33b0852c84452afbaf0f41c2abc954008be7ef77 (diff) | |
download | ale-dcbab18a35d471504260379f3919974747afc165.zip |
Stop errors being generated when jobs are removed from the Dictionary before callbacks fire
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/job.vim | 13 |
1 files 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. |