From aaaad0f5934460dfaf7ef7a29dcf38060c641b43 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Wed, 4 Nov 2020 03:44:08 +0000 Subject: vim-patch:8.2.1947: crash when using "zj" without folds (#13222) Problem: Crash when using "zj" without folds. (Sean Dewar) Solution: Check for at least one fold. (closes vim/vim#7245) https://github.com/vim/vim/commit/c136a3528b7ebb825c3863d701af44f023381181 --- src/nvim/fold.c | 3 +++ src/nvim/testdir/test_fold.vim | 11 +++++++++++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 57001f77ed..96968a5d49 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -888,6 +888,9 @@ int foldMoveTo( // that moves the cursor is used. linenr_T lnum_off = 0; garray_T *gap = &curwin->w_folds; + if (gap->ga_len == 0) { + break; + } bool use_level = false; bool maybe_small = false; linenr_T lnum_found = curwin->w_cursor.lnum; diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index 692f6e4780..e4baa34e4a 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -795,3 +795,14 @@ func Test_fold_delete_first_line() bwipe! set foldmethod& endfunc + +" this was crashing +func Test_move_no_folds() + new + fold + setlocal fdm=expr + normal zj + bwipe! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit