Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use visual mode for operator-pending mode f/t #292

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions plugin/sneak.vim
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ func! sneak#to(op, input, inputlen, count, register, repeatmotion, reverse, incl
call s:ft_hook()
endif

let in_visual = is_op && 2 != a:inclusive && !a:reverse
if in_visual
norm! v
endif

let nextchar = searchpos('\_.', 'n'.(s.search_options_no_s))
let nudge = !a:inclusive && a:repeatmotion && nextchar == s.dosearch('n')
if nudge
Expand All @@ -180,6 +185,9 @@ func! sneak#to(op, input, inputlen, count, register, repeatmotion, reverse, incl
endfor

if 0 == max(matchpos)
if in_visual
exe "norm! \<esc>"
endif
if nudge
call sneak#util#nudge(a:reverse) "undo nudge for t
endif
Expand Down Expand Up @@ -232,11 +240,6 @@ func! sneak#to(op, input, inputlen, count, register, repeatmotion, reverse, incl
call sneak#util#nudge(a:reverse) "undo nudge for t
endif

if is_op && 2 != a:inclusive && !a:reverse
" f/t operations do not apply to the current character; nudge the cursor.
call sneak#util#nudge(1)
endif

if is_op || '' != target
call sneak#util#removehl()
endif
Expand Down