#39 Don't send the Vim buffer to commands before the last in a chain
This commit is contained in:
parent
df2c6df819
commit
eb37d9c1fc
@ -215,6 +215,7 @@ function! s:RunJob(command, generic_job_options) abort
|
|||||||
let l:linter = a:generic_job_options.linter
|
let l:linter = a:generic_job_options.linter
|
||||||
let l:output_stream = a:generic_job_options.output_stream
|
let l:output_stream = a:generic_job_options.output_stream
|
||||||
let l:next_chain_index = a:generic_job_options.next_chain_index
|
let l:next_chain_index = a:generic_job_options.next_chain_index
|
||||||
|
let l:read_buffer = a:generic_job_options.read_buffer
|
||||||
let l:command = a:command
|
let l:command = a:command
|
||||||
|
|
||||||
if l:command =~# '%s'
|
if l:command =~# '%s'
|
||||||
@ -270,11 +271,13 @@ function! s:RunJob(command, generic_job_options) abort
|
|||||||
" Execute the command with the shell, to fix escaping issues.
|
" Execute the command with the shell, to fix escaping issues.
|
||||||
let l:command = split(&shell) + split(&shellcmdflag) + [l:command]
|
let l:command = split(&shell) + split(&shellcmdflag) + [l:command]
|
||||||
|
|
||||||
|
if l:read_buffer
|
||||||
" On Unix machines, we can send the Vim buffer directly.
|
" On Unix machines, we can send the Vim buffer directly.
|
||||||
" This is faster than reading the lines ourselves.
|
" This is faster than reading the lines ourselves.
|
||||||
let l:job_options.in_io = 'buffer'
|
let l:job_options.in_io = 'buffer'
|
||||||
let l:job_options.in_buf = l:buffer
|
let l:job_options.in_buf = l:buffer
|
||||||
endif
|
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 l:job = job_start(l:command, l:job_options)
|
let l:job = job_start(l:command, l:job_options)
|
||||||
@ -293,6 +296,7 @@ function! s:RunJob(command, generic_job_options) abort
|
|||||||
\ 'next_chain_index': l:next_chain_index,
|
\ 'next_chain_index': l:next_chain_index,
|
||||||
\}
|
\}
|
||||||
|
|
||||||
|
if l:read_buffer
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
" In NeoVim, we have to send the buffer lines ourselves.
|
" In NeoVim, we have to send the buffer lines ourselves.
|
||||||
let l:input = join(getbufline(l:buffer, 1, '$'), "\n") . "\n"
|
let l:input = join(getbufline(l:buffer, 1, '$'), "\n") . "\n"
|
||||||
@ -310,6 +314,7 @@ function! s:RunJob(command, generic_job_options) abort
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:InvokeChain(buffer, linter, chain_index, input) abort
|
function! s:InvokeChain(buffer, linter, chain_index, input) abort
|
||||||
@ -364,11 +369,14 @@ function! s:InvokeChain(buffer, linter, chain_index, input) abort
|
|||||||
let l:command = a:linter.command
|
let l:command = a:linter.command
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
let l:is_last_job = l:chain_index >= len(get(a:linter, 'command_chain', [])) - 1
|
||||||
|
|
||||||
call s:RunJob(l:command, {
|
call s:RunJob(l:command, {
|
||||||
\ 'buffer': a:buffer,
|
\ 'buffer': a:buffer,
|
||||||
\ 'linter': a:linter,
|
\ 'linter': a:linter,
|
||||||
\ 'output_stream': l:output_stream,
|
\ 'output_stream': l:output_stream,
|
||||||
\ 'next_chain_index': l:chain_index + 1,
|
\ 'next_chain_index': l:chain_index + 1,
|
||||||
|
\ 'read_buffer': l:is_last_job,
|
||||||
\})
|
\})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user