Skip to content

Commit

Permalink
fix: make skipfold actually move the cursor #276
Browse files Browse the repository at this point in the history
commit e914b73 changed the line 
    call cursor(foldend + 1, 1)
to
    call line(foldedge)
    call col(a:reverse ? 1 : '$')

This is obviously nonsense - in the end, skipfold() never actually moves the
cursor when it says so. The reason no one has caught this so far is that
wherever we use the function, we _continue_ the search loops in this case (on
return value `1`), go on finding the next match, so if the fold is contained by
the window area, we will eventually reach a target outside the fold anyway, if
there is one (by doing some unnecessary work).

fix #274
  • Loading branch information
ggandor authored Jul 3, 2021
1 parent 65e5e46 commit 9e2b501
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions autoload/sneak/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func! sneak#util#wincol1() abort
return c
endf

"Moves the cursor to the first line after the current folded lines.
"Moves the cursor to the outmost position in the current folded area.
"Returns:
" 1 if the cursor was moved
" 0 if the cursor is not in a fold
Expand All @@ -83,8 +83,8 @@ func! sneak#util#skipfold(current_line, reverse) abort
\ || foldedge >= line("w$") "fold ends at/below bottom of window.
return -1
endif
call line(foldedge)
call col(a:reverse ? 1 : '$')
call cursor(foldedge, 0)
call cursor(0, a:reverse ? 1 : col('$'))
return 1
endif
return 0
Expand Down

0 comments on commit 9e2b501

Please sign in to comment.