From 9ad8fd6a1bdff5f0c80cf921df5628d1d322cf82 Mon Sep 17 00:00:00 2001 From: Jesse Harris Date: Thu, 20 Jun 2019 08:35:10 +1000 Subject: Handle powershell unexpected token with newline (#2588) * Newline in unexpected token broke parser * fixed test to properly capture regressions * removed deprecated linter options for powershell --- ale_linters/powershell/powershell.vim | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'ale_linters/powershell') diff --git a/ale_linters/powershell/powershell.vim b/ale_linters/powershell/powershell.vim index 51ded71d..a63191fd 100755 --- a/ale_linters/powershell/powershell.vim +++ b/ale_linters/powershell/powershell.vim @@ -49,11 +49,19 @@ function! ale_linters#powershell#powershell#Handle(buffer, lines) abort let l:matchcount = 1 endif - let l:item = { - \ 'lnum': str2nr(l:match[1]), - \ 'col': str2nr(l:match[2]), - \ 'type': 'E', - \} + " If the match is 0, it was a failed match + " probably due to an unexpected token which + " contained a newline. Reset matchcount. to + " continue to the next match + if !empty(l:match[1]) + let l:item = { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'type': 'E', + \} + else + let l:matchcount = 0 + endif elseif l:matchcount == 2 " Second match[0] grabs the full line in order " to handles the text @@ -84,8 +92,8 @@ endfunction call ale#linter#Define('powershell', { \ 'name': 'powershell', -\ 'executable_callback': 'ale_linters#powershell#powershell#GetExecutable', -\ 'command_callback': 'ale_linters#powershell#powershell#GetCommand', +\ 'executable': function('ale_linters#powershell#powershell#GetExecutable'), +\ 'command': function('ale_linters#powershell#powershell#GetCommand'), \ 'output_stream': 'stdout', \ 'callback': 'ale_linters#powershell#powershell#Handle', \}) -- cgit v1.2.3