All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: rhysd https://rhysd.github.io
2 " Description: Redpen, a proofreading tool (http://redpen.cc)
4 function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
5 " Only one file was passed to redpen. So response array has only one
7 let l:res = get(ale#util#FuzzyJSONDecode(a:lines, []), 0, {})
10 for l:err in get(l:res, 'errors', [])
12 \ 'text': l:err.message,
14 \ 'code': l:err.validator,
17 if has_key(l:err, 'startPosition')
18 let l:item.lnum = l:err.startPosition.lineNum
19 let l:item.col = l:err.startPosition.offset + 1
21 if has_key(l:err, 'endPosition')
22 let l:item.end_lnum = l:err.endPosition.lineNum
23 let l:item.end_col = l:err.endPosition.offset
26 " Fallback to a whole sentence region when a region is not
27 " specified by the error.
28 let l:item.lnum = l:err.lineNum
29 let l:item.col = l:err.sentenceStartColumnNum + 1
32 " Adjust column number for multibyte string
33 let l:line = getline(l:item.lnum)
36 let l:line = l:err.sentence
39 let l:line = split(l:line, '\zs')
44 for l:strlen in map(l:line[0:(l:item.col - 2)], 'strlen(v:val)')
45 let l:col = l:col + l:strlen
48 let l:item.col = l:col + 1
51 if has_key(l:item, 'end_col')
54 for l:strlen in map(l:line[0:(l:item.end_col - 1)], 'strlen(v:val)')
55 let l:col = l:col + l:strlen
58 let l:item.end_col = l:col
61 call add(l:output, l:item)