Skip to content

Commit c136a35

Browse files
committed
patch 8.2.1947: crash when using "zj" without folds
Problem: Crash when using "zj" without folds. (Sean Dewar) Solution: Check for at least one fold. (closes #7245)
1 parent 35efa22 commit c136a35

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/fold.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,8 @@ foldMoveTo(
902902
// that moves the cursor is used.
903903
lnum_off = 0;
904904
gap = &curwin->w_folds;
905+
if (gap->ga_len == 0)
906+
break;
905907
use_level = FALSE;
906908
maybe_small = FALSE;
907909
lnum_found = curwin->w_cursor.lnum;

src/testdir/test_fold.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,4 +835,13 @@ func Test_undo_fold_deletion()
835835
bwipe!
836836
endfunc
837837

838+
" this was crashing
839+
func Test_move_no_folds()
840+
new
841+
fold
842+
setlocal fdm=expr
843+
normal zj
844+
bwipe!
845+
endfunc
846+
838847
" vim: shiftwidth=2 sts=2 expandtab

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1947,
753755
/**/
754756
1946,
755757
/**/

0 commit comments

Comments
 (0)