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 Dec 20, 2018
1 parent 1a0244c commit f6cadc1
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 f6cadc1

Please sign in to comment.