summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/handlers/redpen.vim24
-rw-r--r--test/handler/test_redpen_handler.vader24
2 files changed, 48 insertions, 0 deletions
diff --git a/autoload/ale/handlers/redpen.vim b/autoload/ale/handlers/redpen.vim
index 2fb05684..c136789c 100644
--- a/autoload/ale/handlers/redpen.vim
+++ b/autoload/ale/handlers/redpen.vim
@@ -25,6 +25,30 @@ function! ale#handlers#redpen#HandleRedpenOutput(buffer, lines) abort
let l:item.lnum = l:err.lineNum
let l:item.col = l:err.sentenceStartColumnNum + 1
endif
+
+ " Adjust column number for multibyte string
+ let l:line = getline(l:item.lnum)
+ if l:line is# ''
+ let l:line = l:err.sentence
+ endif
+ let l:line = split(l:line, '\zs')
+
+ if l:item.col >= 2
+ let l:col = 0
+ for l:strlen in map(l:line[0:(l:item.col - 2)], 'strlen(v:val)')
+ let l:col = l:col + l:strlen
+ endfor
+ let l:item.col = l:col + 1
+ endif
+
+ if has_key(l:item, 'end_col')
+ let l:col = 0
+ for l:strlen in map(l:line[0:(l:item.end_col - 1)], 'strlen(v:val)')
+ let l:col = l:col + l:strlen
+ endfor
+ let l:item.end_col = l:col
+ endif
+
call add(l:output, l:item)
endfor
return l:output
diff --git a/test/handler/test_redpen_handler.vader b/test/handler/test_redpen_handler.vader
index f28d6923..4490bcba 100644
--- a/test/handler/test_redpen_handler.vader
+++ b/test/handler/test_redpen_handler.vader
@@ -23,6 +23,15 @@ Execute(redpen handler should handle errors output):
\ 'type': 'W',
\ 'code': 'Spelling',
\ },
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 35,
+ \ 'end_lnum': 1,
+ \ 'end_col': 55,
+ \ 'text': 'Found possibly misspelled word "コードチェック".',
+ \ 'type': 'W',
+ \ 'code': 'Spelling',
+ \ },
\ ],
\ ale#handlers#redpen#HandleRedpenOutput(bufnr(''), [
\ '[',
@@ -50,6 +59,21 @@ Execute(redpen handler should handle errors output):
\ ' "lineNum": 1,',
\ ' "sentenceStartColumnNum": 0,',
\ ' "message": "Found possibly misspelled word \"NeoVim\"."',
+ \ ' },',
+ \ ' {',
+ \ ' "sentence": "ALEはNeoVimとVim8で非同期のコードチェックを実現するプラグインです。",',
+ \ ' "endPosition": {',
+ \ ' "offset": 27,',
+ \ ' "lineNum": 1',
+ \ ' },',
+ \ ' "validator": "Spelling",',
+ \ ' "lineNum": 1,',
+ \ ' "sentenceStartColumnNum": 0,',
+ \ ' "message": "Found possibly misspelled word \"コードチェック\".",',
+ \ ' "startPosition": {',
+ \ ' "offset": 20,',
+ \ ' "lineNum": 1',
+ \ ' }',
\ ' }',
\ ' ]',
\ ' }',