From 831f783493ec761191da48a07536b267cbe565ec Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Thu, 19 Jan 2017 21:01:51 +0100 Subject: Join the lines Neovim passes to ale (#263) * Join the lines Neovim passes to ale Fixes #256 * Refactor line joining into own function * Add test for line joining * Fix the test. Sorry. --- autoload/ale/engine.vim | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'autoload') diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index 005bca43..933be2ac 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -72,22 +72,39 @@ function! s:StopPreviousJobs(buffer, linter) abort let g:ale_buffer_info[a:buffer].job_list = l:new_job_list endfunction -function! s:GatherOutput(job, data) abort - let l:job_id = s:GetJobID(a:job) +function! s:GatherOutputVim(channel, data) abort + let l:job_id = s:GetJobID(ch_getjob(a:channel)) if !has_key(s:job_info_map, l:job_id) return endif - call extend(s:job_info_map[l:job_id].output, a:data) + call add(s:job_info_map[l:job_id].output, a:data) endfunction -function! s:GatherOutputVim(channel, data) abort - call s:GatherOutput(ch_getjob(a:channel), [a:data]) +function! s:GatherOutputNeoVim(job, data, event) abort + let l:job_id = s:GetJobID(a:job) + + if !has_key(s:job_info_map, l:job_id) + return + endif + + " Join the lines passed to ale, because Neovim splits them up. + " a:data is a list of strings, where every item is a new line, except the + " first one, which is the continuation of the last item passed last time. + call ale#engine#JoinNeovimOutput(s:job_info_map[l:job_id].output, a:data) endfunction -function! s:GatherOutputNeoVim(job, data, event) abort - call s:GatherOutput(a:job, a:data) +function! ale#engine#JoinNeovimOutput(output, data) abort + if empty(a:output) + call extend(a:output, a:data) + else + " Extend the previous line, which can be continued. + let a:output[-1] .= get(a:data, 0, '') + + " Add the new lines. + call extend(a:output, a:data[1:]) + endif endfunction function! s:HandleExit(job) abort -- cgit v1.2.3