# HG changeset patch # User Bram Moolenaar # Date 1604430903 -3600 # Node ID 3c72820f88b21f232635515a601ae01f79d41b5d # Parent 6ba0337eba3a30de92a3fec0a3f59804c691e3c2 patch 8.2.1947: crash when using "zj" without folds Commit: https://github.com/vim/vim/commit/c136a3528b7ebb825c3863d701af44f023381181 Author: Bram Moolenaar Date: Tue Nov 3 20:05:40 2020 +0100 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 https://github.com/vim/vim/issues/7245) diff --git a/src/fold.c b/src/fold.c --- a/src/fold.c +++ b/src/fold.c @@ -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; diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -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 diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -751,6 +751,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1947, +/**/ 1946, /**/ 1945,