Skip to content

Commit

Permalink
fix: use visual mode for operator-pending mode f/t
Browse files Browse the repository at this point in the history
f1eb049 (fix for justinmk#177) broke
operator-pending mode f when the target is on eol/eof (justinmk#291). Revert
that commit in order to fix justinmk#291, and introduce an alternative fix for
 justinmk#177: exit visual mode if target is not found.

Fixes justinmk#291, justinmk#177
  • Loading branch information
tomtomjhj committed Mar 31, 2022
1 parent 2a2fe7c commit ed9b04b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions plugin/sneak.vim
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,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 @@ -183,6 +188,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 @@ -235,11 +243,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

0 comments on commit ed9b04b

Please sign in to comment.