]> granicus.if.org Git - vim/commitdiff
patch 8.1.0535: increment/decrement might get interrupted by updating folds v8.1.0535
authorBram Moolenaar <Bram@vim.org>
Fri, 16 Nov 2018 19:54:47 +0000 (20:54 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 16 Nov 2018 19:54:47 +0000 (20:54 +0100)
Problem:    Increment/decrement might get interrupted by updating folds.
Solution:   Disable fold updating for a moment. (Christian Brabandt,
            closes #3599)

src/ops.c
src/version.c

index d6559a2b1e4094525346c46b4a832afdaa77eebd..7564fac7dbbba26add98f2862d6e5307fcdabd1f 100644 (file)
--- a/src/ops.c
+++ b/src/ops.c
@@ -5549,12 +5549,27 @@ op_addsub(
     int                        change_cnt = 0;
     linenr_T           amount = Prenum1;
 
+   // do_addsub() might trigger re-evaluation of 'foldexpr' halfway, when the
+   // buffer is not completly updated yet. Postpone updating folds until before
+   // the call to changed_lines().
+#ifdef FEAT_FOLDING
+   disable_fold_update++;
+#endif
+
     if (!VIsual_active)
     {
        pos = curwin->w_cursor;
        if (u_save_cursor() == FAIL)
+       {
+#ifdef FEAT_FOLDING
+           disable_fold_update--;
+#endif
            return;
+       }
        change_cnt = do_addsub(oap->op_type, &pos, 0, amount);
+#ifdef FEAT_FOLDING
+       disable_fold_update--;
+#endif
        if (change_cnt)
            changed_lines(pos.lnum, 0, pos.lnum + 1, 0L);
     }
@@ -5566,7 +5581,12 @@ op_addsub(
 
        if (u_save((linenr_T)(oap->start.lnum - 1),
                                        (linenr_T)(oap->end.lnum + 1)) == FAIL)
+       {
+#ifdef FEAT_FOLDING
+           disable_fold_update--;
+#endif
            return;
+       }
 
        pos = oap->start;
        for (; pos.lnum <= oap->end.lnum; ++pos.lnum)
@@ -5624,6 +5644,10 @@ op_addsub(
            if (g_cmd && one_change)
                amount += Prenum1;
        }
+
+#ifdef FEAT_FOLDING
+       disable_fold_update--;
+#endif
        if (change_cnt)
            changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
 
index ad633e81492bb39002aac80b12977f8d2ea412a9..eaaf98ae06787c0964937065c21e9fb539fdefa2 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    535,
 /**/
     534,
 /**/