summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-02-17 10:19:44 +0000
committerw0rp <devw0rp@gmail.com>2017-02-17 10:19:44 +0000
commitb21ca4ed4e09bd519ba2943aed17cff909dd71e2 (patch)
tree065f6135b89007d5a70f95d1314dbec3e6a07f2a
parentbdbf36991d2f21feb3be08cfa979c76e548577a1 (diff)
downloadale-b21ca4ed4e09bd519ba2943aed17cff909dd71e2.zip
Use a more reliable method for getting an ID for a job
-rw-r--r--autoload/ale/engine.vim20
-rw-r--r--test/test_vim8_processid_parsing.vader5
2 files changed, 12 insertions, 13 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim
index 593876fb..61db4a1c 100644
--- a/autoload/ale/engine.vim
+++ b/autoload/ale/engine.vim
@@ -9,25 +9,19 @@
" output: The array of lines for the output of the job.
let s:job_info_map = {}
+function! ale#engine#ParseVim8ProcessID(job_string) abort
+ return matchstr(a:job_string, '\d\+') + 0
+endfunction
+
function! s:GetJobID(job) abort
if has('nvim')
"In NeoVim, job values are just IDs.
return a:job
endif
- " In Vim 8, the job is a special variable, and we open a channel for each
- " job. We'll use the ID of the channel instead as the job ID.
- try
- let l:channel_info = ch_info(job_getchannel(a:job))
-
- if !empty(l:channel_info)
- return l:channel_info.id
- endif
- catch
- endtry
-
- " If we fail to get the channel ID for a job, just return a 0 ID.
- return 0
+ " For Vim 8, the job is a different variable type, and we can parse the
+ " process ID from the string.
+ return ale#engine#ParseVim8ProcessID(string(a:job))
endfunction
function! ale#engine#InitBufferInfo(buffer) abort
diff --git a/test/test_vim8_processid_parsing.vader b/test/test_vim8_processid_parsing.vader
new file mode 100644
index 00000000..5ec564e0
--- /dev/null
+++ b/test/test_vim8_processid_parsing.vader
@@ -0,0 +1,5 @@
+Execute(Vim8 Process ID parsing should work):
+ AssertEqual 123, ale#engine#ParseVim8ProcessID('process 123 run')
+ AssertEqual 347, ale#engine#ParseVim8ProcessID('process 347 failed')
+ AssertEqual 789, ale#engine#ParseVim8ProcessID('process 789 dead')
+ AssertEqual 0, ale#engine#ParseVim8ProcessID('no process')