mirror of https://github.com/dense-analysis/ale
Handle there being no process for a job better in Vim 8, re issue #39.
This commit is contained in:
parent
57b157bbae
commit
20a28b7856
|
@ -107,6 +107,11 @@ function! s:FixLoclist(buffer, loclist)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:HandleExit(job)
|
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)
|
let job_id = s:GetJobID(a:job)
|
||||||
|
|
||||||
if !has_key(s:job_info_map, job_id)
|
if !has_key(s:job_info_map, job_id)
|
||||||
|
@ -192,18 +197,18 @@ function! s:ApplyLinter(buffer, linter)
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
if a:linter.output_stream ==# 'stderr'
|
if a:linter.output_stream ==# 'stderr'
|
||||||
" Read from stderr instead of stdout.
|
" Read from stderr instead of stdout.
|
||||||
let a:linter.job = jobstart(command, {
|
let job = jobstart(command, {
|
||||||
\ 'on_stderr': 's:GatherOutputNeoVim',
|
\ 'on_stderr': 's:GatherOutputNeoVim',
|
||||||
\ 'on_exit': 's:HandleExitNeoVim',
|
\ 'on_exit': 's:HandleExitNeoVim',
|
||||||
\})
|
\})
|
||||||
elseif a:linter.output_stream ==# 'both'
|
elseif a:linter.output_stream ==# 'both'
|
||||||
let a:linter.job = jobstart(command, {
|
let job = jobstart(command, {
|
||||||
\ 'on_stdout': 's:GatherOutputNeoVim',
|
\ 'on_stdout': 's:GatherOutputNeoVim',
|
||||||
\ 'on_stderr': 's:GatherOutputNeoVim',
|
\ 'on_stderr': 's:GatherOutputNeoVim',
|
||||||
\ 'on_exit': 's:HandleExitNeoVim',
|
\ 'on_exit': 's:HandleExitNeoVim',
|
||||||
\})
|
\})
|
||||||
else
|
else
|
||||||
let a:linter.job = jobstart(command, {
|
let job = jobstart(command, {
|
||||||
\ 'on_stdout': 's:GatherOutputNeoVim',
|
\ 'on_stdout': 's:GatherOutputNeoVim',
|
||||||
\ 'on_exit': 's:HandleExitNeoVim',
|
\ 'on_exit': 's:HandleExitNeoVim',
|
||||||
\})
|
\})
|
||||||
|
@ -236,11 +241,15 @@ function! s:ApplyLinter(buffer, linter)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Vim 8 will read the stdin from the file's buffer.
|
" 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
|
endif
|
||||||
|
|
||||||
|
" Sometimes the job can be failed to be created at all in Vim 8.
|
||||||
|
if job != 'no process'
|
||||||
|
let a:linter.job = job
|
||||||
|
|
||||||
" Store the ID for the job in the map to read back again.
|
" Store the ID for the job in the map to read back again.
|
||||||
let s:job_info_map[s:GetJobID(a:linter.job)] = {
|
let s:job_info_map[s:GetJobID(job)] = {
|
||||||
\ 'linter': a:linter,
|
\ 'linter': a:linter,
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'output': [],
|
\ 'output': [],
|
||||||
|
@ -251,6 +260,7 @@ function! s:ApplyLinter(buffer, linter)
|
||||||
call jobsend(a:linter.job, join(getline(1, '$'), "\n") . "\n")
|
call jobsend(a:linter.job, join(getline(1, '$'), "\n") . "\n")
|
||||||
call jobclose(a:linter.job, 'stdin')
|
call jobclose(a:linter.job, 'stdin')
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:TimerHandler(...)
|
function! s:TimerHandler(...)
|
||||||
|
|
Loading…
Reference in New Issue