mirror of
https://github.com/dense-analysis/ale
synced 2025-02-16 12:16:56 +00:00
Add end_col of matched forbidden word (#4556)
This commit is contained in:
parent
7ba88ad343
commit
969f7b080f
@ -24,14 +24,19 @@ endfunction
|
|||||||
function! ale#handlers#cspell#Handle(buffer, lines) abort
|
function! ale#handlers#cspell#Handle(buffer, lines) abort
|
||||||
" Look for lines like the following:
|
" Look for lines like the following:
|
||||||
"
|
"
|
||||||
" /home/user/repos/ale/README.md:723:48 - Unknown word (stylelint)
|
" /home/user/repos/ale/README.md:3:128 - Unknown word (Neovim)
|
||||||
let l:pattern = '\v^.*:(\d+):(\d+) - (.*)$'
|
" match1: 3
|
||||||
|
" match2: 128
|
||||||
|
" match3: Unknown word (Neovim)
|
||||||
|
" match4: Neovim
|
||||||
|
let l:pattern = '\v^.*:(\d+):(\d+) - ([^\(]+\(([^\)]+)\).*)$'
|
||||||
let l:output = []
|
let l:output = []
|
||||||
|
|
||||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||||
call add(l:output, {
|
call add(l:output, {
|
||||||
\ 'lnum': l:match[1] + 0,
|
\ 'lnum': l:match[1] + 0,
|
||||||
\ 'col': l:match[2] + 0,
|
\ 'col': l:match[2] + 0,
|
||||||
|
\ 'end_col': l:match[2] + len(l:match[4]) - 1,
|
||||||
\ 'text': l:match[3],
|
\ 'text': l:match[3],
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\})
|
\})
|
||||||
|
@ -2,12 +2,13 @@ Execute(The cspell handler should handle cspell output):
|
|||||||
AssertEqual
|
AssertEqual
|
||||||
\ [
|
\ [
|
||||||
\ {
|
\ {
|
||||||
\ 'lnum': 721,
|
\ 'lnum': 3,
|
||||||
\ 'col': 18,
|
\ 'col': 128,
|
||||||
|
\ 'end_col': 133,
|
||||||
\ 'type': 'W',
|
\ 'type': 'W',
|
||||||
\ 'text': 'Unknown word (stylelint)',
|
\ 'text': 'Unknown word (Neovim)',
|
||||||
\ },
|
\ },
|
||||||
\ ],
|
\ ],
|
||||||
\ ale#handlers#cspell#Handle(bufnr(''),
|
\ ale#handlers#cspell#Handle(bufnr(''),
|
||||||
\ '/:721:18 - Unknown word (stylelint)'
|
\ '/:3:128 - Unknown word (Neovim)'
|
||||||
\)
|
\)
|
||||||
|
Loading…
Reference in New Issue
Block a user