Skip to content

Commit 3147978

Browse files
committed
fix: highlighting stopped because of negative byte count
When the cursor is at the beginning of the file the code silently fails because a negative byte is used for the jump and consequently highlighting is stopped.
1 parent 662e7b1 commit 3147978

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugin/cool.vim

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ function! s:StartHL()
3131
endif
3232
let g:cool_is_searching = 1
3333
let [pos, rpos] = [winsaveview(), getpos('.')]
34-
silent! exe "keepjumps go".(line2byte('.')+col('.')-(v:searchforward ? 2 : 0))
34+
let byte = line2byte('.')+col('.')-(v:searchforward ? 2 : 0)
35+
36+
if byte <= 0
37+
return
38+
endif
39+
silent! exe "keepjumps go".byte
3540
try
3641
silent keepjumps norm! n
3742
if getpos('.') != rpos

0 commit comments

Comments
 (0)