Skip to content

Commit

Permalink
fix virtual col for multibyte JK motion when g:EasyMotion_startofline=0
Browse files Browse the repository at this point in the history
  • Loading branch information
SolaWing committed Nov 19, 2017
1 parent 342549e commit 8f6d41c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
2 changes: 1 addition & 1 deletion autoload/EasyMotion.vim
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ function! EasyMotion#JK(visualmode, direction) " {{{
if g:EasyMotion_startofline
call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', 0)
else
let vcol = EasyMotion#helper#vcol('.')
let vcol = getcurpos()[4]
let pattern = printf('^.\{-}\zs\(\%%<%dv.\%%>%dv\|$\)', vcol + 1, vcol)
call s:EasyMotion(pattern, a:direction, a:visualmode ? visualmode() : '', 0)
endif
Expand Down
17 changes: 0 additions & 17 deletions autoload/EasyMotion/helper.vim
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,6 @@ function! EasyMotion#helper#include_multibyte_char(str) "{{{
return strlen(a:str) != EasyMotion#helper#strchars(a:str)
endfunction "}}}

function! EasyMotion#helper#vcol(expr) abort
let col_num = col(a:expr)
let line = getline(a:expr)
let before_line = col_num > 2 ? line[: col_num - 2]
\ : col_num is# 2 ? line[0]
\ : ''
let vcol_num = 1
for c in split(before_line, '\zs')
let vcol_num += c is# "\t" ? s:_virtual_tab2spacelen(vcol_num) : len(c)
endfor
return vcol_num
endfunction

function! s:_virtual_tab2spacelen(col_num) abort
return &tabstop - ((a:col_num - 1) % &tabstop)
endfunction

"}}}

" Restore 'cpoptions' {{{
Expand Down

0 comments on commit 8f6d41c

Please sign in to comment.