diff options
author | w0rp <devw0rp@gmail.com> | 2018-03-23 12:17:49 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-03-23 12:17:54 +0000 |
commit | dbf530e87fde81397712a85ed87b6a15131afd4c (patch) | |
tree | 9ab411f54da1126eb6ecc68209152ca49dc9ad84 /ale_linters | |
parent | ec5750f57b6b98b46cf041f32bcc5d890f3e7e37 (diff) | |
download | ale-dbf530e87fde81397712a85ed87b6a15131afd4c.zip |
Fix #1373 - Fix a bug with Fish errors not being handled on Linux
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/fish/fish.vim | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/ale_linters/fish/fish.vim b/ale_linters/fish/fish.vim index 19158cb0..87ede29a 100644 --- a/ale_linters/fish/fish.vim +++ b/ale_linters/fish/fish.vim @@ -7,22 +7,53 @@ function! ale_linters#fish#fish#Handle(buffer, lines) abort " home/.config/fish/functions/foo.fish (line 1): Missing end to balance this function definition " function foo " ^ - " <W> fish: Error while reading file .config/fish/functions/foo.fish - let l:pattern = '^.* (line \(\d\+\)): \(.*\)$' + " + " OR, patterns such as: + " + " Unsupported use of '||'. In fish, please use 'COMMAND; or COMMAND'. + " /tmp/vLz620o/258/test.fish (line 2): if set -q SSH_CLIENT || set -q SSH_TTY + " ^ + " + " fish -n can return errors in either format. + let l:pattern = '^\(.* (line \(\d\+\)): \)\(.*\)$' + let l:column_pattern = '^ *\^' let l:output = [] + let l:column_offset = 0 + let l:last_line_with_message = '' + + for l:line in a:lines + " Look for error lines first. + let l:match = matchlist(l:line, l:pattern) + + if !empty(l:match) + if !empty(l:last_line_with_message) + let l:text = l:last_line_with_message + else + let l:text = l:match[3] + endif + + let l:column_offset = len(l:match[1]) + + let l:last_line_with_message = '' + call add(l:output, { + \ 'col': 0, + \ 'lnum': str2nr(l:match[2]), + \ 'text': l:text, + \}) + else + " Look for column markers like ' ^' second. + " The column index will be set according to how long the line is. + let l:column_match = matchstr(l:line, l:column_pattern) - let l:i = 0 - while l:i < len(a:lines) - let l:match = matchlist(a:lines[l:i], l:pattern) - if len(l:match) && len(l:match[2]) - call add(l:output, { - \ 'col': len(a:lines[l:i + 2]), - \ 'lnum': str2nr(l:match[1]), - \ 'text': l:match[2], - \}) - endif - let l:i += 1 - endwhile + if !empty(l:column_match) && !empty(l:output) + let l:output[-1].col = len(l:column_match) - l:column_offset + let l:last_line_with_message = '' + else + let l:last_line_with_message = l:line + let l:column_offset = 0 + endif + endif + endfor return l:output endfunction |