From c165c7c5d11eb827a3be6bab691f20eeb6f6e487 Mon Sep 17 00:00:00 2001 From: w0rp Date: Tue, 26 Dec 2017 18:15:51 +0000 Subject: [PATCH] Fix #1251 - Handle an empty list in the line callback when NeoVim crashes --- autoload/ale/job.vim | 2 +- test/test_line_join.vader | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim index 2e0b8ca2..9cebcf5b 100644 --- a/autoload/ale/job.vim +++ b/autoload/ale/job.vim @@ -36,7 +36,7 @@ function! ale#job#JoinNeovimOutput(job, last_line, data, mode, callback) abort let l:lines[0] = a:last_line . l:lines[0] let l:new_last_line = a:data[-1] else - let l:new_last_line = a:last_line . a:data[0] + let l:new_last_line = a:last_line . get(a:data, 0, '') endif for l:line in l:lines diff --git a/test/test_line_join.vader b/test/test_line_join.vader index c93b192f..25cefbcf 100644 --- a/test/test_line_join.vader +++ b/test/test_line_join.vader @@ -17,6 +17,12 @@ After: delfunction LineCallback delfunction RawCallback +Execute (ALE should handle empty Lists for the lines): + let g:last_line = ale#job#JoinNeovimOutput(1, '', [], 'nl', function('LineCallback')) + + AssertEqual [], g:lines + AssertEqual '', g:last_line + Execute (ALE should pass on full lines for NeoVim): let g:last_line = ale#job#JoinNeovimOutput(1, '', ['x', 'y', ''], 'nl', function('LineCallback'))