aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/fold.c3
-rw-r--r--src/nvim/testdir/test_fold.vim7
2 files changed, 9 insertions, 1 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 654aa6d5ba..0593c16999 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -902,8 +902,9 @@ int foldMoveTo(
bool last = false;
for (;; ) {
if (!foldFind(gap, curwin->w_cursor.lnum - lnum_off, &fp)) {
- if (!updown)
+ if (!updown || gap->ga_len == 0) {
break;
+ }
/* When moving up, consider a fold above the cursor; when
* moving down consider a fold below the cursor. */
diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim
index 3c90c45952..88ce64b9eb 100644
--- a/src/nvim/testdir/test_fold.vim
+++ b/src/nvim/testdir/test_fold.vim
@@ -815,4 +815,11 @@ func Test_fold_create_delete_create()
bwipe!
endfunc
+" this was crashing
+func Test_fold_create_delete()
+ new
+ norm zFzFzdzj
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab