From 2c40707baa13a53cac4137ffb8b2ac67f50cea63 Mon Sep 17 00:00:00 2001 From: Brandon Simmons Date: Sat, 23 Apr 2022 13:50:17 +0100 Subject: patch 8.2.4813: pasting text while indent folding may mess up folds Problem: Pasting text while indent folding may mess up folds. Solution: Adjust the way folds are split. (Brandon Simmons, closes #10254) --- src/fold.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/fold.c') diff --git a/src/fold.c b/src/fold.c index 8078e3af88..229cb2ad2d 100644 --- a/src/fold.c +++ b/src/fold.c @@ -1128,7 +1128,7 @@ cloneFoldGrowArray(garray_T *from, garray_T *to) // foldFind() {{{2 /* * Search for line "lnum" in folds of growarray "gap". - * Set *fpp to the fold struct for the fold that contains "lnum" or + * Set "*fpp" to the fold struct for the fold that contains "lnum" or * the first fold below it (careful: it can be beyond the end of the array!). * Returns FALSE when there is no fold that contains "lnum". */ @@ -2911,7 +2911,8 @@ foldSplit( // any between top and bot, they have been removed by the caller. gap1 = &fp->fd_nested; gap2 = &fp[1].fd_nested; - if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) + (void)foldFind(gap1, bot + 1 - fp->fd_top, &fp2); + if (fp2 != NULL) { len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2); if (len > 0 && ga_grow(gap2, len) == OK) -- cgit v1.2.3