diff src/fold.c @ 28929:2ac9beab876c v8.2.4987

patch 8.2.4987: after deletion a small fold may be closable Commit: https://github.com/vim/vim/commit/3fcccf94e8bc142d2c79c3b62087145896df6b36 Author: Brandon Simmons <simmsbra@gmail.com> Date: Fri May 20 18:25:21 2022 +0100 patch 8.2.4987: after deletion a small fold may be closable Problem: After deletion a small fold may be closable. Solution: Check for a reverse range. (Brandon Simmons, closes https://github.com/vim/vim/issues/10457)
author Bram Moolenaar <Bram@vim.org>
date Fri, 20 May 2022 19:30:06 +0200
parents 980eaa09f940
children 65946c949965
line wrap: on
line diff
--- a/src/fold.c
+++ b/src/fold.c
@@ -829,10 +829,18 @@ foldUpdate(win_T *wp, linenr_T top, line
 
     if (wp->w_folds.ga_len > 0)
     {
-	// Mark all folds from top to bot as maybe-small.
-	(void)foldFind(&wp->w_folds, top, &fp);
+	linenr_T	maybe_small_start = top;
+	linenr_T	maybe_small_end = bot;
+
+	// Mark all folds from top to bot (or bot to top) as maybe-small.
+	if (top > bot)
+	{
+	    maybe_small_start = bot;
+	    maybe_small_end = top;
+	}
+	(void)foldFind(&wp->w_folds, maybe_small_start, &fp);
 	while (fp < (fold_T *)wp->w_folds.ga_data + wp->w_folds.ga_len
-		&& fp->fd_top < bot)
+		&& fp->fd_top <= maybe_small_end)
 	{
 	    fp->fd_small = MAYBE;
 	    ++fp;
@@ -2165,7 +2173,7 @@ foldUpdateIEMS(win_T *wp, linenr_T top, 
 	bot = wp->w_buffer->b_ml.ml_line_count;
 	wp->w_foldinvalid = FALSE;
 
-	// Mark all folds a maybe-small.
+	// Mark all folds as maybe-small.
 	setSmallMaybe(&wp->w_folds);
     }