From 64538589150b5cb5da4703528f5cb81f46449f2f Mon Sep 17 00:00:00 2001 From: haya14busa Date: Tue, 6 May 2014 10:41:54 +0900 Subject: [PATCH] Escape `*` (asterisc) correctly - Especially for 2-key find motions - fix #151 - Thanks @wilywampa --- autoload/EasyMotion.vim | 2 +- t/smartsign_spec.vim | 81 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 44d3fb6..8149365 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -509,7 +509,7 @@ function! s:escape_regexp_char(char) "{{{ " Get escaped char from given dictionary " return '' if char is not find " Used inside `[]` - return escape(a:char, '.$^~\[]') + return escape(a:char, '.$^~\[]*') endfunction "}}} function! s:convertSmartcase(re, char) "{{{ let re = a:re diff --git a/t/smartsign_spec.vim b/t/smartsign_spec.vim index f02d504..d9d7d14 100644 --- a/t/smartsign_spec.vim +++ b/t/smartsign_spec.vim @@ -386,6 +386,87 @@ describe 'Basic Smartsign feature with 1-key findmotions with US layout' end "}}} +" Smartsign with 2-key find motions with US layout {{{ +describe 'Smartsign with 2-key find motions with US layout' + before + new + let g:EasyMotion_keys = '123456789' + let g:EasyMotion_use_smartsign_us = 1 + map s (easymotion-s2) + call EasyMotion#init() + call AddLine(' -_ =+ ;: [{ ]} `~ ''" \|') + call AddLine(' 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0)') + call AddLine(' ,< .> /?') + call AddLine(' -_ =+ ;: [{ ]} `~ ''" \|') + call AddLine(' 1! 2@ 3# 4$ 5% 6^ 7& 8* 9( 0)') + call AddLine(' ,< .> /?') + " 123456789012345678901234567890 + " 1 2 3 + end + + after + close! + end + + it 'works well' + " Default position + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,' '] + + " ,< + normal s,,1 + Expect CursorPos() == [l,2,','] + normal! 0 + Expect CursorPos() == [l,1,' '] + normal s,,3 + Expect CursorPos() == [l,1,' '] + normal! 0 + normal s, 1 + Expect CursorPos() == [l,3,'<'] + normal! 0 + normal s<<1 + Expect CursorPos() == [l,1,' '] + normal! 0 + normal s,<1 + Expect CursorPos() == [l,2,','] + normal! 0 + normal s<,1 + Expect CursorPos() == [l,1,' '] + normal! 0 + end + it ': s,,3' + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,' '] + normal s,,3 + Expect CursorPos() == [l,1,' '] + normal! 0 + end + + it 'escape * asterisc #151' + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,' '] + normal s1*22 + Expect CursorPos() == [l,1,' '] + normal! 0 + normal s8*1 + Expect CursorPos() == [l+1,23,'8'] + normal! 0 + normal s881 + Expect CursorPos() == [l+1,23,'8'] + normal! 0 + normal s**1 + Expect CursorPos() == [l+1,1,' '] + normal! 0 + normal s*81 + Expect CursorPos() == [l+1,1,' '] + normal! 0 + end +end +"}}} + " Smartsign with 2-key find motions with JP layout {{{ describe 'Smartsign with 2-key find motions with JP layout' before