Fix #605 - Support vcol: 1 for multi-byte character positions

This commit is contained in:
w0rp
2018-04-08 17:17:30 +01:00
parent 121e806423
commit 91d7e81ebc
4 changed files with 63 additions and 2 deletions

View File

@@ -311,3 +311,13 @@ function! ale#util#StopPartialTimer(timer_id) abort
call remove(s:partial_timers, a:timer_id)
endif
endfunction
" Given a possibly multi-byte string and a 1-based character position on a
" line, return the 1-based byte position on that line.
function! ale#util#Col(str, chr) abort
if a:chr < 2
return a:chr
endif
return strlen(join(split(a:str, '\zs')[0:a:chr - 2], '')) + 1
endfunction