diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/fold.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_fold.vim | 10 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 96968a5d49..24a73a5b9f 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -616,7 +616,11 @@ void foldCreate(win_T *wp, pos_T start, pos_T end) break; } } - i = (int)(fp - (fold_T *)gap->ga_data); + if (gap->ga_len == 0) { + i = 0; + } else { + i = (int)(fp - (fold_T *)gap->ga_data); + } } ga_grow(gap, 1); diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index e4baa34e4a..3c90c45952 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -805,4 +805,14 @@ func Test_move_no_folds() bwipe! endfunc +" this was crashing +func Test_fold_create_delete_create() + new + fold + fold + normal zd + fold + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab |