Skip to content

Commit

Permalink
patch 8.2.1947: crash when using "zj" without folds
Browse files Browse the repository at this point in the history
Problem:    Crash when using "zj" without folds. (Sean Dewar)
Solution:   Check for at least one fold. (closes #7245)
  • Loading branch information
brammool committed Nov 3, 2020
1 parent 35efa22 commit c136a35
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/fold.c
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ foldMoveTo(
// that moves the cursor is used.
lnum_off = 0;
gap = &curwin->w_folds;
if (gap->ga_len == 0)
break;
use_level = FALSE;
maybe_small = FALSE;
lnum_found = curwin->w_cursor.lnum;
Expand Down
9 changes: 9 additions & 0 deletions src/testdir/test_fold.vim
Original file line number Diff line number Diff line change
Expand Up @@ -835,4 +835,13 @@ func Test_undo_fold_deletion()
bwipe!
endfunc

" this was crashing
func Test_move_no_folds()
new
fold
setlocal fdm=expr
normal zj
bwipe!
endfunc

" vim: shiftwidth=2 sts=2 expandtab
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1947,
/**/
1946,
/**/
Expand Down

0 comments on commit c136a35

Please sign in to comment.