aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/fold.c5
-rw-r--r--src/nvim/testdir/test_fold.vim20
2 files changed, 23 insertions, 2 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c
index 5032646d7e..ad8418034a 100644
--- a/src/nvim/fold.c
+++ b/src/nvim/fold.c
@@ -2227,8 +2227,9 @@ static linenr_T foldUpdateIEMSRecurse(
if (getlevel == foldlevelMarker && flp->start <= flp->lvl - level
&& flp->lvl > 0) {
(void)foldFind(gap, startlnum - 1, &fp);
- if (fp >= ((fold_T *)gap->ga_data) + gap->ga_len
- || fp->fd_top >= startlnum) {
+ if (fp != NULL
+ && (fp >= ((fold_T *)gap->ga_data) + gap->ga_len
+ || fp->fd_top >= startlnum)) {
fp = NULL;
}
}
diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim
index fcdf888b96..2cc5b47cb0 100644
--- a/src/nvim/testdir/test_fold.vim
+++ b/src/nvim/testdir/test_fold.vim
@@ -796,6 +796,26 @@ func Test_fold_delete_first_line()
set foldmethod&
endfunc
+func Test_undo_fold_deletion()
+ new
+ set fdm=marker
+ let lines =<< trim END
+ " {{{
+ " }}}1
+ " {{{
+ END
+ call setline(1, lines)
+ 3d
+ g/"/d
+ undo
+ redo
+ " eval getline(1, '$')->assert_equal([''])
+ eval assert_equal(getline(1, '$'), [''])
+
+ set fdm&vim
+ bwipe!
+endfunc
+
" this was crashing
func Test_move_no_folds()
new