]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4403: ml_get error with nested folds and deleting lines v8.2.4403
authorBram Moolenaar <Bram@vim.org>
Wed, 16 Feb 2022 20:30:52 +0000 (20:30 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 16 Feb 2022 20:30:52 +0000 (20:30 +0000)
Problem:    ml_get error with nested folds and deleting lines.
Solution:   Correct the last line number before calling hasFoldingWin().

src/change.c
src/version.c

index 771f7675b6790c44b4c237d1c72d07984735c58d..d1ecb60bbf42f66111dbd52e94f6bb51211659cf 100644 (file)
@@ -552,6 +552,8 @@ changed_common(
     {
        if (wp->w_buffer == curbuf)
        {
+           linenr_T last = lnume + xtra - 1;  // last line after the change
+
            // Mark this window to be redrawn later.
            if (wp->w_redr_type < VALID)
                wp->w_redr_type = VALID;
@@ -561,7 +563,7 @@ changed_common(
 #ifdef FEAT_FOLDING
            // Update the folds for this window.  Can't postpone this, because
            // a following operator might work on the whole fold: ">>dd".
-           foldUpdate(wp, lnum, lnume + xtra - 1);
+           foldUpdate(wp, lnum, last);
 
            // The change may cause lines above or below the change to become
            // included in a fold.  Set lnum/lnume to the first/last line that
@@ -571,8 +573,8 @@ changed_common(
            i = hasFoldingWin(wp, lnum, &lnum, NULL, FALSE, NULL);
            if (wp->w_cursor.lnum == lnum)
                wp->w_cline_folded = i;
-           i = hasFoldingWin(wp, lnume, NULL, &lnume, FALSE, NULL);
-           if (wp->w_cursor.lnum == lnume)
+           i = hasFoldingWin(wp, last, NULL, &last, FALSE, NULL);
+           if (wp->w_cursor.lnum == last)
                wp->w_cline_folded = i;
 
            // If the changed line is in a range of previously folded lines,
index e1ecbac89ab7d12cda288603efa76416851c64de..b788e12e3e522ed17bc4998a58eea906d11596d4 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4403,
 /**/
     4402,
 /**/