diff --git a/autoload/sneak/streak.vim b/autoload/sneak/streak.vim index 492c536..3d90416 100644 --- a/autoload/sneak/streak.vim +++ b/autoload/sneak/streak.vim @@ -90,15 +90,16 @@ func! s:do_streak(s, st) call s:after() let v = sneak#util#isvisualop(a:st.op) + let mappedto = maparg(choice, v ? 'x' : 'n') if choice == "\" && overflow[0] > 0 call cursor(overflow[0], overflow[1]) return 1 "overflow => decorate next N matches elseif -1 != index(["\", "\", "\"], choice) return 0 "exit streak-mode. - elseif maparg(choice, v ? 'x' : 'n') =~# 'V\?Sneak.\?\(Fwd\|Next\|Forward\)' + elseif mappedto =~# 'V\?Sneak.\?\(Fwd\|Next\|Forward\)' call sneak#rpt(v, 1, 0) - elseif maparg(choice, v ? 'x' : 'n') =~# 'V\?Sneak.\?\(Bck\|Previous\|Backward\)' + elseif mappedto =~# 'V\?Sneak.\?\(Bck\|Previous\|Backward\)' call sneak#rpt(v, 1, 1) elseif !has_key(s:matchmap, choice) "press _any_ invalid key to escape. call feedkeys(choice) "exit streak-mode and fall through to Vim. diff --git a/tests/test.vader b/tests/test.vader index 25dbfa8..f66e090 100644 --- a/tests/test.vader +++ b/tests/test.vader @@ -247,6 +247,38 @@ Expect: | batch_size | Fixnum | nil | number of maximum items to be assigned at once | | logger | Logger | nil | logger instance for debug logs | +########################################################### +# clever-s _not_ in streak-mode + +Given: + abcdef abcdef abcdef + abcdef abcdef abcdef + abcdef abcdef abcdef + +Do (clever-s): + sabsax + +Expect: + abcdef abcdef axbcdef + abcdef abcdef abcdef + abcdef abcdef abcdef + +Do (clever-s): + sab3sax + +Expect: + abcdef abcdef abcdef + abcdef axbcdef abcdef + abcdef abcdef abcdef + +Do (clever-s): + sabsssssssSSax + +Expect: + abcdef abcdef abcdef + abcdef abcdef abcdef + axbcdef abcdef abcdef + ########################################################### Given: @@ -321,6 +353,30 @@ Expect: abcdef ``=2Bd-a3/+ =QWEOIJ/+ ~~~!!! ! { } abc AAaab abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+ +# sadly we must force-exit via because feedkeys() in do_streak() +# breaks macros/Vader +Do (clever-s, streak-mode): + sab\2six + +Expect: + abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+ + `=QWEOIJ/+ ~~~!!! ! { } abc AAaxab + abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+ + +Do (clever-s, visual-mode, streak-mode): + vsabsd + +Expect: + bc AAaab + abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+ + +Do (clever-s, backwards clever-s, visual-mode, streak-mode): + jvsabsssZd + +Expect: + abcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+ + bcdef ``=2Bd-a3/+ abCDef ``=2Bd-a3/+ + Execute (cleanup): let g:sneak#streak = 0 call sneak#init()