summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorINOUE Yosuke <glabra@users.noreply.github.com>2018-03-19 03:12:47 +0900
committerw0rp <w0rp@users.noreply.github.com>2018-03-18 18:12:47 +0000
commit68b9399d4c4cdca8a29b5e6125d44779c52def81 (patch)
tree46087c3c132df60c537ac6fa6b7a634be3685ad2 /autoload
parent434f22e44a1ed5a5be2628c1fdd5906cf1c9bc46 (diff)
downloadale-68b9399d4c4cdca8a29b5e6125d44779c52def81.zip
handle multibyte string when linting text with redpen (#1416)
* handle multibyte string when linting text with redpen * fix error when no string is provided, fix test's expect value * remove ambiguious `==` operator
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/handlers/redpen.vim24
1 files changed, 24 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