summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2016-10-08 21:04:42 +0100
committerw0rp <devw0rp@gmail.com>2016-10-08 21:04:42 +0100
commit20a28b7856fd2377527add58161a1c40c00f7232 (patch)
tree4af8542384c36405501e14d83292ed8ba79590ba /plugin
parent57b157bbae7e8fb60a74680f9c435b5bdd53ed1b (diff)
downloadale-20a28b7856fd2377527add58161a1c40c00f7232.zip
Handle there being no process for a job better in Vim 8, re issue #39.
Diffstat (limited to 'plugin')
-rw-r--r--plugin/ale/zmain.vim38
1 files changed, 24 insertions, 14 deletions
diff --git a/plugin/ale/zmain.vim b/plugin/ale/zmain.vim
index 6a6ead4a..7b11bd4b 100644
--- a/plugin/ale/zmain.vim
+++ b/plugin/ale/zmain.vim
@@ -107,6 +107,11 @@ function! s:FixLoclist(buffer, loclist)
endfunction
function! s:HandleExit(job)
+ if a:job == 'no process'
+ " Stop right away when the job is not valid in Vim 8.
+ return
+ endif
+
let job_id = s:GetJobID(a:job)
if !has_key(s:job_info_map, job_id)
@@ -192,18 +197,18 @@ function! s:ApplyLinter(buffer, linter)
if has('nvim')
if a:linter.output_stream ==# 'stderr'
" Read from stderr instead of stdout.
- let a:linter.job = jobstart(command, {
+ let job = jobstart(command, {
\ 'on_stderr': 's:GatherOutputNeoVim',
\ 'on_exit': 's:HandleExitNeoVim',
\})
elseif a:linter.output_stream ==# 'both'
- let a:linter.job = jobstart(command, {
+ let job = jobstart(command, {
\ 'on_stdout': 's:GatherOutputNeoVim',
\ 'on_stderr': 's:GatherOutputNeoVim',
\ 'on_exit': 's:HandleExitNeoVim',
\})
else
- let a:linter.job = jobstart(command, {
+ let job = jobstart(command, {
\ 'on_stdout': 's:GatherOutputNeoVim',
\ 'on_exit': 's:HandleExitNeoVim',
\})
@@ -236,20 +241,25 @@ function! s:ApplyLinter(buffer, linter)
endif
" Vim 8 will read the stdin from the file's buffer.
- let a:linter.job = job_start(l:command, l:job_options)
+ let job = job_start(l:command, l:job_options)
endif
- " Store the ID for the job in the map to read back again.
- let s:job_info_map[s:GetJobID(a:linter.job)] = {
- \ 'linter': a:linter,
- \ 'buffer': a:buffer,
- \ 'output': [],
- \}
+ " Sometimes the job can be failed to be created at all in Vim 8.
+ if job != 'no process'
+ let a:linter.job = job
- if has('nvim')
- " For NeoVim, we have to send the text in the buffer to the command.
- call jobsend(a:linter.job, join(getline(1, '$'), "\n") . "\n")
- call jobclose(a:linter.job, 'stdin')
+ " Store the ID for the job in the map to read back again.
+ let s:job_info_map[s:GetJobID(job)] = {
+ \ 'linter': a:linter,
+ \ 'buffer': a:buffer,
+ \ 'output': [],
+ \}
+
+ if has('nvim')
+ " For NeoVim, we have to send the text in the buffer to the command.
+ call jobsend(a:linter.job, join(getline(1, '$'), "\n") . "\n")
+ call jobclose(a:linter.job, 'stdin')
+ endif
endif
endfunction