#1006 Fix raw message handling for LSP support in NeoVim

This commit is contained in:
w0rp 2017-11-06 22:46:32 +00:00
parent 8e7ede3be8
commit 55757e3d78
2 changed files with 14 additions and 27 deletions

View file

@ -25,6 +25,11 @@ endfunction
" Note that jobs and IDs are the same thing on NeoVim. " Note that jobs and IDs are the same thing on NeoVim.
function! ale#job#JoinNeovimOutput(job, last_line, data, mode, callback) abort function! ale#job#JoinNeovimOutput(job, last_line, data, mode, callback) abort
if a:mode is# 'raw'
call a:callback(a:job, join(a:data, "\n"))
return ''
endif
let l:lines = a:data[:-2] let l:lines = a:data[:-2]
if len(a:data) > 1 if len(a:data) > 1
@ -34,15 +39,9 @@ function! ale#job#JoinNeovimOutput(job, last_line, data, mode, callback) abort
let l:new_last_line = a:last_line . a:data[0] let l:new_last_line = a:last_line . a:data[0]
endif endif
if a:mode is# 'raw' for l:line in l:lines
if !empty(l:lines) call a:callback(a:job, l:line)
call a:callback(a:job, join(l:lines, "\n") . "\n") endfor
endif
else
for l:line in l:lines
call a:callback(a:job, l:line)
endfor
endif
return l:new_last_line return l:new_last_line
endfunction endfunction

View file

@ -62,8 +62,8 @@ Execute (ALE should pass on full lines for NeoVim for raw data):
Execute (ALE should pass on a single long line): Execute (ALE should pass on a single long line):
let g:last_line = ale#job#JoinNeovimOutput(1, '', ['x'], 'raw', function('RawCallback')) let g:last_line = ale#job#JoinNeovimOutput(1, '', ['x'], 'raw', function('RawCallback'))
AssertEqual '', g:data AssertEqual 'x', g:data
AssertEqual 'x', g:last_line AssertEqual '', g:last_line
Execute (ALE should handle just a single line of output): Execute (ALE should handle just a single line of output):
let g:last_line = ale#job#JoinNeovimOutput(1, '', ['x', ''], 'raw', function('RawCallback')) let g:last_line = ale#job#JoinNeovimOutput(1, '', ['x', ''], 'raw', function('RawCallback'))
@ -71,20 +71,8 @@ Execute (ALE should handle just a single line of output):
AssertEqual "x\n", g:data AssertEqual "x\n", g:data
AssertEqual '', g:last_line AssertEqual '', g:last_line
Execute (ALE should join two incomplete pieces of large lines together): Execute (ALE should pass on two lines and one incomplete one):
let g:last_line = ale#job#JoinNeovimOutput(1, 'x', ['y'], 'raw', function('RawCallback')) let g:last_line = ale#job#JoinNeovimOutput(1, '', ['y', 'z', 'a'], 'raw', function('RawCallback'))
AssertEqual '', g:data AssertEqual "y\nz\na", g:data
AssertEqual 'xy', g:last_line AssertEqual '', g:last_line
Execute (ALE join incomplete lines, and set new ones):
let g:last_line = ale#job#JoinNeovimOutput(1, 'x', ['y', 'z', 'a'], 'raw', function('RawCallback'))
AssertEqual "xy\nz\n", g:data
AssertEqual 'a', g:last_line
Execute (ALE join incomplete lines, and set new ones, with two elements):
let g:last_line = ale#job#JoinNeovimOutput(1, 'x', ['y', 'z'], 'raw', function('RawCallback'))
AssertEqual "xy\n", g:data
AssertEqual 'z', g:last_line