mirror of
https://github.com/dense-analysis/ale
synced 2024-12-23 22:53:40 +00:00
#1006 Fix raw message handling for LSP support in NeoVim
This commit is contained in:
parent
3cbf716d72
commit
8e71f82f8f
@ -25,6 +25,11 @@ endfunction
|
||||
|
||||
" Note that jobs and IDs are the same thing on NeoVim.
|
||||
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]
|
||||
|
||||
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]
|
||||
endif
|
||||
|
||||
if a:mode is# 'raw'
|
||||
if !empty(l:lines)
|
||||
call a:callback(a:job, join(l:lines, "\n") . "\n")
|
||||
endif
|
||||
else
|
||||
for l:line in l:lines
|
||||
call a:callback(a:job, l:line)
|
||||
endfor
|
||||
endif
|
||||
for l:line in l:lines
|
||||
call a:callback(a:job, l:line)
|
||||
endfor
|
||||
|
||||
return l:new_last_line
|
||||
endfunction
|
||||
|
@ -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):
|
||||
let g:last_line = ale#job#JoinNeovimOutput(1, '', ['x'], 'raw', function('RawCallback'))
|
||||
|
||||
AssertEqual '', g:data
|
||||
AssertEqual 'x', g:last_line
|
||||
AssertEqual 'x', g:data
|
||||
AssertEqual '', g:last_line
|
||||
|
||||
Execute (ALE should handle just a single line of output):
|
||||
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 '', g:last_line
|
||||
|
||||
Execute (ALE should join two incomplete pieces of large lines together):
|
||||
let g:last_line = ale#job#JoinNeovimOutput(1, 'x', ['y'], 'raw', function('RawCallback'))
|
||||
Execute (ALE should pass on two lines and one incomplete one):
|
||||
let g:last_line = ale#job#JoinNeovimOutput(1, '', ['y', 'z', 'a'], 'raw', function('RawCallback'))
|
||||
|
||||
AssertEqual '', g:data
|
||||
AssertEqual 'xy', 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
|
||||
AssertEqual "y\nz\na", g:data
|
||||
AssertEqual '', g:last_line
|
||||
|
Loading…
Reference in New Issue
Block a user