Skip to content

Commit 942f158

Browse files
committed
fix: disable SneakCurrent in exclusive motion
Use of SneakCurrent with inclusive=0 (t-like) motion wasn't considered properly: - The semantics are that it's like a search highlight for "match under cursor", but exclusive motion lands the cursor *next* to the match - SneakCurrent's implementation assumes the cursor is at match start when the highlight is shown, which caused a hl bug extending the hl beyond the match on exclusive
1 parent 536dd6a commit 942f158

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

autoload/sneak.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,9 @@ func! sneak#to(op, input, inputlen, count, register, repeatmotion, reverse, incl
213213
let w:sneak_hl_id = matchadd('Sneak',
214214
\ (s.prefix).(s.match_pattern).(s.search).'\|'.curln_pattern.(s.search))
215215

216-
if matchlen > 1
216+
" Highlight match under cursor
217+
" - not appropriate for exclusive motions: the cursor is next to the match
218+
if a:inclusive != 0 && matchlen > 1
217219
let w:sneak_cur_hl = matchadd('SneakCurrent', '\%#.\{'.matchlen.'}')
218220
endif
219221

0 commit comments

Comments
 (0)