mirror of
https://github.com/dense-analysis/ale
synced 2024-12-25 15:42:26 +00:00
Send the buffers to the linters using getbufline() on Windows, re issue #39
This commit is contained in:
parent
20a28b7856
commit
f17a660888
@ -215,11 +215,10 @@ function! s:ApplyLinter(buffer, linter)
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
let job_options = {
|
let job_options = {
|
||||||
|
\ 'in_mode': 'nl',
|
||||||
\ 'out_mode': 'nl',
|
\ 'out_mode': 'nl',
|
||||||
\ 'err_mode': 'nl',
|
\ 'err_mode': 'nl',
|
||||||
\ 'close_cb': function('s:HandleExitVim'),
|
\ 'close_cb': function('s:HandleExitVim'),
|
||||||
\ 'in_io': 'buffer',
|
|
||||||
\ 'in_buf': a:buffer,
|
|
||||||
\}
|
\}
|
||||||
|
|
||||||
if a:linter.output_stream ==# 'stderr'
|
if a:linter.output_stream ==# 'stderr'
|
||||||
@ -238,14 +237,19 @@ function! s:ApplyLinter(buffer, linter)
|
|||||||
" othwerwise %PATHTEXT% will not be used to programs ending int
|
" othwerwise %PATHTEXT% will not be used to programs ending int
|
||||||
" .cmd, .bat, .exe, etc.
|
" .cmd, .bat, .exe, etc.
|
||||||
let l:command = 'cmd /c ' . l:command
|
let l:command = 'cmd /c ' . l:command
|
||||||
|
else
|
||||||
|
" On Unix machines, we can send the Vim buffer directly.
|
||||||
|
" This is faster than reading the lines ourselves.
|
||||||
|
let job_options.in_io = 'buffer'
|
||||||
|
let job_options.in_buf = a:buffer
|
||||||
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 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.
|
" Only proceed if the job is being run.
|
||||||
if job != 'no process'
|
if has('nvim') || (job != 'no process' && job_status(job) == 'run')
|
||||||
let a:linter.job = job
|
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.
|
||||||
@ -256,9 +260,21 @@ function! s:ApplyLinter(buffer, linter)
|
|||||||
\}
|
\}
|
||||||
|
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
" For NeoVim, we have to send the text in the buffer to the command.
|
" In NeoVim, we have to send the buffer lines ourselves.
|
||||||
call jobsend(a:linter.job, join(getline(1, '$'), "\n") . "\n")
|
let input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n"
|
||||||
call jobclose(a:linter.job, 'stdin')
|
|
||||||
|
call jobsend(job, input)
|
||||||
|
call jobclose(job, 'stdin')
|
||||||
|
elseif has('win32')
|
||||||
|
" On Windows, we have to send the buffer lines ourselves,
|
||||||
|
" as there are issues with Windows and 'in_buf'
|
||||||
|
let input = join(getbufline(a:buffer, 1, '$'), "\n") . "\n"
|
||||||
|
let channel = job_getchannel(job)
|
||||||
|
|
||||||
|
if ch_status(channel) == 'open'
|
||||||
|
call ch_sendraw(channel, input)
|
||||||
|
call ch_close_in(channel)
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
@ -395,7 +411,7 @@ endif
|
|||||||
if g:ale_lint_on_enter
|
if g:ale_lint_on_enter
|
||||||
augroup ALERunOnEnterGroup
|
augroup ALERunOnEnterGroup
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufEnter,BufRead * call ALELint(0)
|
autocmd BufEnter,BufRead * call ALELint(100)
|
||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user