summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-11-06 22:46:32 +0000
committerw0rp <devw0rp@gmail.com>2017-11-06 22:53:27 +0000
commit55757e3d78229d6f902f253a426cb0a752817560 (patch)
tree50d73a45f67c2c8f448ca208e524ea9652c90c3a
parent8e7ede3be88407ce109368c4979a74f4024933e0 (diff)
downloadale-55757e3d78229d6f902f253a426cb0a752817560.zip
#1006 Fix raw message handling for LSP support in NeoVim
-rw-r--r--autoload/ale/job.vim17
-rw-r--r--test/test_line_join.vader24
2 files changed, 14 insertions, 27 deletions
diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim
index 0f6b8577..e6a75c88 100644
--- a/autoload/ale/job.vim
+++ b/autoload/ale/job.vim
@@ -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
diff --git a/test/test_line_join.vader b/test/test_line_join.vader
index 04264296..c93b192f 100644
--- a/test/test_line_join.vader
+++ b/test/test_line_join.vader
@@ -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'))
-
- 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'))
+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 "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