Implement bidirectional t motion and fix exclusive & inclusive flag

Implement: bidirectional t including within line, two-key, multi find
motion.
Fix: misuse of exclusive -> inclusive
Fix: bidirectional find motion inclusive flag
Add: test case for bidirectional t motion

close #6
This commit is contained in:
haya14busa 2014-01-21 11:10:12 +09:00
parent c2c15d74ab
commit a0c2b760fe
3 changed files with 150 additions and 29 deletions

View File

@ -49,6 +49,8 @@ function! EasyMotion#reset()
\ 'within_line' : 0, \ 'within_line' : 0,
\ 'dot_repeat' : 0, \ 'dot_repeat' : 0,
\ 'regexp' : 0, \ 'regexp' : 0,
\ 'bd_t' : 0,
\ 'find_bd' : 0,
\ } \ }
let s:current = { let s:current = {
\ 'is_operator' : 0, \ 'is_operator' : 0,
@ -61,20 +63,39 @@ endfunction "}}}
" Motion Functions: {{{ " Motion Functions: {{{
" -- Find Motion ------------------------- " -- Find Motion -------------------------
function! EasyMotion#S(num_strokes, visualmode, direction) " {{{ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 if a:direction == 1
let is_inclusive = 0
else
" Handle bi-direction later
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
endif
let s:flag.find_bd = a:direction == 2 ? 1 : 0
let re = s:findMotion(a:num_strokes) let re = s:findMotion(a:num_strokes)
if s:handleEmpty(re, a:visualmode) | return | endif if s:handleEmpty(re, a:visualmode) | return | endif
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive) call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
function! EasyMotion#T(num_strokes, visualmode, direction) " {{{ function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 if a:direction == 1
let is_inclusive = 0
else
" Handle bi-direction later
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
endif
let s:flag.find_bd = a:direction == 2 ? 1 : 0
let re = s:findMotion(a:num_strokes) let re = s:findMotion(a:num_strokes)
if s:handleEmpty(re, a:visualmode) | return | endif if s:handleEmpty(re, a:visualmode) | return | endif
let re = a:direction == 1 ? '\('.re.'\)\zs.' : '.\ze\('.re.'\)' if a:direction == 2
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive) let s:flag.bd_t = 1
elseif a:direction == 1
let re = '\('.re.'\)\zs.'
else
let re = '.\ze\('.re.'\)'
endif
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
" -- Word Motion ------------------------- " -- Word Motion -------------------------
function! EasyMotion#WB(visualmode, direction) " {{{ function! EasyMotion#WB(visualmode, direction) " {{{
"FIXME: inconsistent with default vim motion
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0) call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
endfunction " }}} endfunction " }}}
@ -84,13 +105,13 @@ function! EasyMotion#WBW(visualmode, direction) " {{{
endfunction " }}} endfunction " }}}
function! EasyMotion#E(visualmode, direction) " {{{ function! EasyMotion#E(visualmode, direction) " {{{
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 let is_inclusive = mode(1) ==# 'no' ? 1 : 0
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive) call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
function! EasyMotion#EW(visualmode, direction) " {{{ function! EasyMotion#EW(visualmode, direction) " {{{
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 let is_inclusive = mode(1) ==# 'no' ? 1 : 0
call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive) call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
" -- JK Motion --------------------------- " -- JK Motion ---------------------------
function! EasyMotion#JK(visualmode, direction) " {{{ function! EasyMotion#JK(visualmode, direction) " {{{
@ -123,31 +144,43 @@ function! EasyMotion#JumpToAnywhere(visualmode, direction) " {{{
endfunction " }}} endfunction " }}}
" -- Line Motion ------------------------- " -- Line Motion -------------------------
function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 if a:direction == 1
let is_inclusive = 0
else
" Handle bi-direction later
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
endif
let s:flag.find_bd = a:direction == 2 ? 1 : 0
let s:flag.within_line = 1 let s:flag.within_line = 1
let re = s:findMotion(a:num_strokes) let re = s:findMotion(a:num_strokes)
if s:handleEmpty(re, a:visualmode) | return | endif if s:handleEmpty(re, a:visualmode) | return | endif
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive) call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 if a:direction == 1
let is_inclusive = 0
else
" Handle bi-direction later
let is_inclusive = mode(1) ==# 'no' ? 1 : 0
endif
let s:flag.find_bd = a:direction == 2 ? 1 : 0
let s:flag.within_line = 1 let s:flag.within_line = 1
let re = s:findMotion(a:num_strokes) let re = s:findMotion(a:num_strokes)
if s:handleEmpty(re, a:visualmode) | return | endif if s:handleEmpty(re, a:visualmode) | return | endif
let re = a:direction == 1 ? '\('.re.'\)\zs.' : '.\ze\('.re.'\)' let re = a:direction == 1 ? '\('.re.'\)\zs.' : '.\ze\('.re.'\)'
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive) call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
function! EasyMotion#WBL(visualmode, direction) " {{{ function! EasyMotion#WBL(visualmode, direction) " {{{
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 let is_inclusive = mode(1) ==# 'no' ? 1 : 0
let s:flag.within_line = 1 let s:flag.within_line = 1
call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0) call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0)
endfunction " }}} endfunction " }}}
function! EasyMotion#EL(visualmode, direction) " {{{ function! EasyMotion#EL(visualmode, direction) " {{{
let s:flag.within_line = 1 let s:flag.within_line = 1
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 let is_inclusive = mode(1) ==# 'no' ? 1 : 0
call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive) call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
function! EasyMotion#LineAnywhere(visualmode, direction) " {{{ function! EasyMotion#LineAnywhere(visualmode, direction) " {{{
let s:flag.within_line = 1 let s:flag.within_line = 1
@ -310,9 +343,9 @@ function! EasyMotion#Repeat(visualmode) " {{{
let direction = s:previous.direction let direction = s:previous.direction
let s:flag.within_line = s:previous.line_flag let s:flag.within_line = s:previous.line_flag
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
let is_exclusive = mode(1) ==# 'no' ? 1 : 0 let is_inclusive = mode(1) ==# 'no' ? 1 : 0
call s:EasyMotion(re, direction, a:visualmode ? visualmode() : '', is_exclusive) call s:EasyMotion(re, direction, a:visualmode ? visualmode() : '', is_inclusive)
endfunction " }}} endfunction " }}}
function! EasyMotion#DotRepeat(visualmode) " {{{ function! EasyMotion#DotRepeat(visualmode) " {{{
" Repeat previous motion with previous targets " Repeat previous motion with previous targets
@ -323,13 +356,13 @@ function! EasyMotion#DotRepeat(visualmode) " {{{
let re = s:dot_repeat.regexp let re = s:dot_repeat.regexp
let direction = s:dot_repeat.direction let direction = s:dot_repeat.direction
let is_exclusive = s:dot_repeat.is_exclusive let is_inclusive = s:dot_repeat.is_inclusive
let s:flag.within_line = s:dot_repeat.line_flag let s:flag.within_line = s:dot_repeat.line_flag
let s:current.is_operator = 1 let s:current.is_operator = 1
for cnt in range(v:count1) for cnt in range(v:count1)
let s:flag.dot_repeat = 1 " s:EasyMotion() always call reset let s:flag.dot_repeat = 1 " s:EasyMotion() always call reset
silent call s:EasyMotion(re, direction, 0, is_exclusive) silent call s:EasyMotion(re, direction, 0, is_inclusive)
endfor endfor
endfunction " }}} endfunction " }}}
function! EasyMotion#NextPrevious(visualmode, direction) " {{{ function! EasyMotion#NextPrevious(visualmode, direction) " {{{
@ -1082,7 +1115,7 @@ function! s:DotPromptUser(groups) "{{{
return s:PromptUser(target, a:allows_repeat, a:fixed_column) return s:PromptUser(target, a:allows_repeat, a:fixed_column)
endif endif
endfunction "}}} endfunction "}}}
function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{
" For Special Function {{{ " For Special Function {{{
" For SelectLines(), to highlight previous selected line " For SelectLines(), to highlight previous selected line
let hlcurrent = a:0 >= 1 ? a:1 : 0 let hlcurrent = a:0 >= 1 ? a:1 : 0
@ -1108,7 +1141,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
let s:previous['regexp'] = a:regexp let s:previous['regexp'] = a:regexp
let s:previous['direction'] = a:direction let s:previous['direction'] = a:direction
let s:previous['line_flag'] = s:flag.within_line == 1 ? 1 : 0 let s:previous['line_flag'] = s:flag.within_line == 1 ? 1 : 0
let s:previous['is_exclusive'] = a:is_exclusive let s:previous['is_inclusive'] = a:is_inclusive
let s:previous['operator'] = v:operator let s:previous['operator'] = v:operator
endif endif
" To avoid side effect of overwriting buffer for tpope/repeat " To avoid side effect of overwriting buffer for tpope/repeat
@ -1152,12 +1185,20 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
endif endif
" }}} " }}}
" Handle bi-directional t motion {{{
if s:flag.bd_t == 1
let regexp = '\('.a:regexp.'\)\zs.'
else
let regexp = a:regexp
endif
"}}}
" Construct match dict {{{ " Construct match dict {{{
while 1 while 1
" Note: searchpos() has side effect which call jump cursor position. " Note: searchpos() has side effect which call jump cursor position.
" You can disable this side effect by add 'n' flags, " You can disable this side effect by add 'n' flags,
" but in this case, it's better to allows jump side effect. " but in this case, it's better to allows jump side effect.
let pos = searchpos(a:regexp, search_direction . search_at_cursor, search_stopline) let pos = searchpos(regexp, search_direction . search_at_cursor, search_stopline)
let search_at_cursor = '' let search_at_cursor = ''
" Reached end of search range " Reached end of search range
@ -1180,6 +1221,11 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
"}}} "}}}
" Handle bidirection "{{{ " Handle bidirection "{{{
" For bi-directional t motion {{{
if s:flag.bd_t == 1
let regexp = '.\ze\('.a:regexp.'\)'
endif
"}}}
" Reconstruct match dict " Reconstruct match dict
if a:direction == 2 if a:direction == 2
" Forward " Forward
@ -1196,7 +1242,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
let search_stopline = !empty(a:visualmode) ? c_pos[0] : orig_pos[0] let search_stopline = !empty(a:visualmode) ? c_pos[0] : orig_pos[0]
endif endif
while 1 while 1
let pos = searchpos(a:regexp, '', search_stopline) let pos = searchpos(regexp, '', search_stopline)
" Reached end of search range " Reached end of search range
if pos == [0, 0] if pos == [0, 0]
break break
@ -1316,7 +1362,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
" support dot repeat {{{ " support dot repeat {{{
" Use visual mode to emulate dot repeat " Use visual mode to emulate dot repeat
normal! v normal! v
if s:dot_repeat.is_exclusive == 0 if s:dot_repeat.is_inclusive == 0
if s:dot_repeat.direction == 0 "Forward if s:dot_repeat.direction == 0 "Forward
let coords[1] -= 1 let coords[1] -= 1
elseif s:dot_repeat.direction == 1 "Backward elseif s:dot_repeat.direction == 1 "Backward
@ -1334,8 +1380,17 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
exec 'normal! ' . cmd exec 'normal! ' . cmd
"}}} "}}}
else else
" Handle operator-pending mode {{{ " Handle inclusive & exclusive {{{
if a:is_exclusive == 1 " Overwrite inclusive flag for special case
let is_exclusive = 0
if s:flag.find_bd == 1
" for bi-directional s(f) & t
let is_backward = EasyMotion#helper#is_greater_coords(orig_pos, coords) < 0
if is_backward != 0
let is_exclusive = 1
endif
endif
if a:is_inclusive == 1 && is_exclusive == 0
" Exclusive motion requires that we eat one more " Exclusive motion requires that we eat one more
" character to the right if we're using " character to the right if we're using
" a forward motion " a forward motion
@ -1366,7 +1421,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{
let s:dot_repeat.regexp = a:regexp let s:dot_repeat.regexp = a:regexp
let s:dot_repeat.direction = a:direction let s:dot_repeat.direction = a:direction
let s:dot_repeat.line_flag = s:flag.within_line == 1 ? 1 : 0 let s:dot_repeat.line_flag = s:flag.within_line == 1 ? 1 : 0
let s:dot_repeat.is_exclusive = a:is_exclusive let s:dot_repeat.is_inclusive = a:is_inclusive
let s:dot_repeat.operator = v:operator let s:dot_repeat.operator = v:operator
"}}} "}}}
silent! call repeat#set("\<Plug>(easymotion-dotrepeat)") silent! call repeat#set("\<Plug>(easymotion-dotrepeat)")

View File

@ -162,33 +162,39 @@ call s:find_motion_map_helper({
\ 's' : {'fnc': 'S' , 'cnt': 1, 'direction': 2}, \ 's' : {'fnc': 'S' , 'cnt': 1, 'direction': 2},
\ 't' : {'fnc': 'T' , 'cnt': 1, 'direction': 0}, \ 't' : {'fnc': 'T' , 'cnt': 1, 'direction': 0},
\ 'T' : {'fnc': 'T' , 'cnt': 1, 'direction': 1}, \ 'T' : {'fnc': 'T' , 'cnt': 1, 'direction': 1},
\ 'bd-t' : {'fnc': 'T', 'cnt': 1, 'direction': 2},
\ 'fl' : {'fnc': 'SL', 'cnt': 1, 'direction': 0}, \ 'fl' : {'fnc': 'SL', 'cnt': 1, 'direction': 0},
\ 'Fl' : {'fnc': 'SL', 'cnt': 1, 'direction': 1}, \ 'Fl' : {'fnc': 'SL', 'cnt': 1, 'direction': 1},
\ 'sl' : {'fnc': 'SL', 'cnt': 1, 'direction': 2}, \ 'sl' : {'fnc': 'SL', 'cnt': 1, 'direction': 2},
\ 'tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 0}, \ 'tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 0},
\ 'Tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 1}, \ 'Tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 1},
\ 'bd-tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 2},
\ \
\ 'f2' : {'fnc': 'S' , 'cnt': 2, 'direction': 0}, \ 'f2' : {'fnc': 'S' , 'cnt': 2, 'direction': 0},
\ 'F2' : {'fnc': 'S' , 'cnt': 2, 'direction': 1}, \ 'F2' : {'fnc': 'S' , 'cnt': 2, 'direction': 1},
\ 's2' : {'fnc': 'S' , 'cnt': 2, 'direction': 2}, \ 's2' : {'fnc': 'S' , 'cnt': 2, 'direction': 2},
\ 't2' : {'fnc': 'T' , 'cnt': 2, 'direction': 0}, \ 't2' : {'fnc': 'T' , 'cnt': 2, 'direction': 0},
\ 'T2' : {'fnc': 'T' , 'cnt': 2, 'direction': 1}, \ 'T2' : {'fnc': 'T' , 'cnt': 2, 'direction': 1},
\ 'bd-t2' : {'fnc': 'T', 'cnt': 2, 'direction': 2},
\ 'fl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 0}, \ 'fl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 0},
\ 'Fl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 1}, \ 'Fl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 1},
\ 'sl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 2}, \ 'sl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 2},
\ 'tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 0}, \ 'tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 0},
\ 'Tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 1}, \ 'Tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 1},
\ 'bd-tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 2},
\ \
\ 'fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 0}, \ 'fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 0},
\ 'Fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 1}, \ 'Fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 1},
\ 'sn' : {'fnc': 'S' , 'cnt': -1, 'direction': 2}, \ 'sn' : {'fnc': 'S' , 'cnt': -1, 'direction': 2},
\ 'tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 0}, \ 'tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 0},
\ 'Tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 1}, \ 'Tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 1},
\ 'bd-tn' : {'fnc': 'T', 'cnt': -1, 'direction': 2},
\ 'fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 0}, \ 'fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 0},
\ 'Fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 1}, \ 'Fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 1},
\ 'sln' : {'fnc': 'SL', 'cnt': -1, 'direction': 2}, \ 'sln' : {'fnc': 'SL', 'cnt': -1, 'direction': 2},
\ 'tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 0}, \ 'tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 0},
\ 'Tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 1}, \ 'Tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 1},
\ 'bd-tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 2},
\ }) \ })
"}}} "}}}

View File

@ -1,7 +1,7 @@
"============================================================================= "=============================================================================
" FILE: t/easymotion_spec.vim " FILE: t/easymotion_spec.vim
" AUTHOR: haya14busa " AUTHOR: haya14busa
" Last Change: 20 Jan 2014. " Last Change: 21 Jan 2014.
" Test: https://github.com/kana/vim-vspec " Test: https://github.com/kana/vim-vspec
" Refer: https://github.com/rhysd/clever-f.vim " Refer: https://github.com/rhysd/clever-f.vim
" Description: EasyMotion test with vim-vspec " Description: EasyMotion test with vim-vspec
@ -55,6 +55,10 @@ describe 'Default settings'
Expect maparg('<Plug>(easymotion-T)', 'n') ==# ':<C-U>call EasyMotion#T(1,0,1)<CR>' Expect maparg('<Plug>(easymotion-T)', 'n') ==# ':<C-U>call EasyMotion#T(1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-T)', 'o') ==# ':<C-U>call EasyMotion#T(1,0,1)<CR>' Expect maparg('<Plug>(easymotion-T)', 'o') ==# ':<C-U>call EasyMotion#T(1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-T)', 'v') ==# '<Esc>:<C-U>call EasyMotion#T(1,1,1)<CR>' Expect maparg('<Plug>(easymotion-T)', 'v') ==# '<Esc>:<C-U>call EasyMotion#T(1,1,1)<CR>'
" bd-t
Expect maparg('<Plug>(easymotion-bd-t)', 'n') ==# ':<C-U>call EasyMotion#T(1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-t)', 'o') ==# ':<C-U>call EasyMotion#T(1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-t)', 'v') ==# '<Esc>:<C-U>call EasyMotion#T(1,1,2)<CR>'
" sl " sl
Expect maparg('<Plug>(easymotion-sl)', 'n') ==# ':<C-U>call EasyMotion#SL(1,0,2)<CR>' Expect maparg('<Plug>(easymotion-sl)', 'n') ==# ':<C-U>call EasyMotion#SL(1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-sl)', 'o') ==# ':<C-U>call EasyMotion#SL(1,0,2)<CR>' Expect maparg('<Plug>(easymotion-sl)', 'o') ==# ':<C-U>call EasyMotion#SL(1,0,2)<CR>'
@ -75,6 +79,10 @@ describe 'Default settings'
Expect maparg('<Plug>(easymotion-Tl)', 'n') ==# ':<C-U>call EasyMotion#TL(1,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tl)', 'n') ==# ':<C-U>call EasyMotion#TL(1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tl)', 'o') ==# ':<C-U>call EasyMotion#TL(1,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tl)', 'o') ==# ':<C-U>call EasyMotion#TL(1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tl)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(1,1,1)<CR>' Expect maparg('<Plug>(easymotion-Tl)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(1,1,1)<CR>'
" bd-tl
Expect maparg('<Plug>(easymotion-bd-tl)', 'n') ==# ':<C-U>call EasyMotion#TL(1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tl)', 'o') ==# ':<C-U>call EasyMotion#TL(1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tl)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(1,1,2)<CR>'
"}}} "}}}
" Two Char Find Motion: {{{ " Two Char Find Motion: {{{
@ -102,6 +110,10 @@ describe 'Default settings'
Expect maparg('<Plug>(easymotion-sl2)', 'n') ==# ':<C-U>call EasyMotion#SL(2,0,2)<CR>' Expect maparg('<Plug>(easymotion-sl2)', 'n') ==# ':<C-U>call EasyMotion#SL(2,0,2)<CR>'
Expect maparg('<Plug>(easymotion-sl2)', 'o') ==# ':<C-U>call EasyMotion#SL(2,0,2)<CR>' Expect maparg('<Plug>(easymotion-sl2)', 'o') ==# ':<C-U>call EasyMotion#SL(2,0,2)<CR>'
Expect maparg('<Plug>(easymotion-sl2)', 'v') ==# '<Esc>:<C-U>call EasyMotion#SL(2,1,2)<CR>' Expect maparg('<Plug>(easymotion-sl2)', 'v') ==# '<Esc>:<C-U>call EasyMotion#SL(2,1,2)<CR>'
" bd-t2
Expect maparg('<Plug>(easymotion-bd-t2)', 'n') ==# ':<C-U>call EasyMotion#T(2,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-t2)', 'o') ==# ':<C-U>call EasyMotion#T(2,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-t2)', 'v') ==# '<Esc>:<C-U>call EasyMotion#T(2,1,2)<CR>'
" fl2 " fl2
Expect maparg('<Plug>(easymotion-fl2)', 'n') ==# ':<C-U>call EasyMotion#SL(2,0,0)<CR>' Expect maparg('<Plug>(easymotion-fl2)', 'n') ==# ':<C-U>call EasyMotion#SL(2,0,0)<CR>'
Expect maparg('<Plug>(easymotion-fl2)', 'o') ==# ':<C-U>call EasyMotion#SL(2,0,0)<CR>' Expect maparg('<Plug>(easymotion-fl2)', 'o') ==# ':<C-U>call EasyMotion#SL(2,0,0)<CR>'
@ -118,6 +130,10 @@ describe 'Default settings'
Expect maparg('<Plug>(easymotion-Tl2)', 'n') ==# ':<C-U>call EasyMotion#TL(2,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tl2)', 'n') ==# ':<C-U>call EasyMotion#TL(2,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tl2)', 'o') ==# ':<C-U>call EasyMotion#TL(2,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tl2)', 'o') ==# ':<C-U>call EasyMotion#TL(2,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tl2)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(2,1,1)<CR>' Expect maparg('<Plug>(easymotion-Tl2)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(2,1,1)<CR>'
" bd-tl2
Expect maparg('<Plug>(easymotion-bd-tl2)', 'n') ==# ':<C-U>call EasyMotion#TL(2,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tl2)', 'o') ==# ':<C-U>call EasyMotion#TL(2,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tl2)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(2,1,2)<CR>'
"}}} "}}}
" Multi Char Find Motion: {{{ " Multi Char Find Motion: {{{
@ -141,6 +157,10 @@ describe 'Default settings'
Expect maparg('<Plug>(easymotion-Tn)', 'n') ==# ':<C-U>call EasyMotion#T(-1,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tn)', 'n') ==# ':<C-U>call EasyMotion#T(-1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tn)', 'o') ==# ':<C-U>call EasyMotion#T(-1,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tn)', 'o') ==# ':<C-U>call EasyMotion#T(-1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tn)', 'v') ==# '<Esc>:<C-U>call EasyMotion#T(-1,1,1)<CR>' Expect maparg('<Plug>(easymotion-Tn)', 'v') ==# '<Esc>:<C-U>call EasyMotion#T(-1,1,1)<CR>'
" bd-tn
Expect maparg('<Plug>(easymotion-bd-tn)', 'n') ==# ':<C-U>call EasyMotion#T(-1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tn)', 'o') ==# ':<C-U>call EasyMotion#T(-1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tn)', 'v') ==# '<Esc>:<C-U>call EasyMotion#T(-1,1,2)<CR>'
" sln " sln
Expect maparg('<Plug>(easymotion-sln)', 'n') ==# ':<C-U>call EasyMotion#SL(-1,0,2)<CR>' Expect maparg('<Plug>(easymotion-sln)', 'n') ==# ':<C-U>call EasyMotion#SL(-1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-sln)', 'o') ==# ':<C-U>call EasyMotion#SL(-1,0,2)<CR>' Expect maparg('<Plug>(easymotion-sln)', 'o') ==# ':<C-U>call EasyMotion#SL(-1,0,2)<CR>'
@ -161,6 +181,10 @@ describe 'Default settings'
Expect maparg('<Plug>(easymotion-Tln)', 'n') ==# ':<C-U>call EasyMotion#TL(-1,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tln)', 'n') ==# ':<C-U>call EasyMotion#TL(-1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tln)', 'o') ==# ':<C-U>call EasyMotion#TL(-1,0,1)<CR>' Expect maparg('<Plug>(easymotion-Tln)', 'o') ==# ':<C-U>call EasyMotion#TL(-1,0,1)<CR>'
Expect maparg('<Plug>(easymotion-Tln)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(-1,1,1)<CR>' Expect maparg('<Plug>(easymotion-Tln)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(-1,1,1)<CR>'
" bd-tln
Expect maparg('<Plug>(easymotion-bd-tln)', 'n') ==# ':<C-U>call EasyMotion#TL(-1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tln)', 'o') ==# ':<C-U>call EasyMotion#TL(-1,0,2)<CR>'
Expect maparg('<Plug>(easymotion-bd-tln)', 'v') ==# '<Esc>:<C-U>call EasyMotion#TL(-1,1,2)<CR>'
"}}} "}}}
end end
@ -1134,4 +1158,40 @@ describe 'EasyMotion regexp'
end end
"}}} "}}}
" bi-directional t motion {{{
describe 'bi-directional t motion'
before
new
let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
let g:EasyMotion_use_regexp = 1
map t <Plug>(easymotion-bd-t)
call EasyMotion#init()
call AddLine('poge1 2huga 3hiyo 4poyo')
" 12345678901234567890123
end
after
let g:EasyMotion_use_regexp = 0
close!
end
" provide bidirectional motion with one key mapping {{{
it 'provide bidirectional motion with one key mapping'
normal! 0
let l = line('.')
Expect CursorPos() == [l,1,'p']
normal thb
Expect CursorPos() == [l,13,'3']
normal! h
Expect CursorPos() == [l,12,' ']
normal thb
Expect CursorPos() == [l,9,'u']
end
"}}}
end
"}}}
" vim: fdm=marker:et:ts=4:sw=4:sts=4 " vim: fdm=marker:et:ts=4:sw=4:sts=4