Skip to content

Commit 6b73188

Browse files
committed
patch 8.1.0535: increment/decrement might get interrupted by updating folds
Problem: Increment/decrement might get interrupted by updating folds. Solution: Disable fold updating for a moment. (Christian Brabandt, closes #3599)
1 parent 25a494c commit 6b73188

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/ops.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5549,12 +5549,27 @@ op_addsub(
55495549
int change_cnt = 0;
55505550
linenr_T amount = Prenum1;
55515551

5552+
// do_addsub() might trigger re-evaluation of 'foldexpr' halfway, when the
5553+
// buffer is not completly updated yet. Postpone updating folds until before
5554+
// the call to changed_lines().
5555+
#ifdef FEAT_FOLDING
5556+
disable_fold_update++;
5557+
#endif
5558+
55525559
if (!VIsual_active)
55535560
{
55545561
pos = curwin->w_cursor;
55555562
if (u_save_cursor() == FAIL)
5563+
{
5564+
#ifdef FEAT_FOLDING
5565+
disable_fold_update--;
5566+
#endif
55565567
return;
5568+
}
55575569
change_cnt = do_addsub(oap->op_type, &pos, 0, amount);
5570+
#ifdef FEAT_FOLDING
5571+
disable_fold_update--;
5572+
#endif
55585573
if (change_cnt)
55595574
changed_lines(pos.lnum, 0, pos.lnum + 1, 0L);
55605575
}
@@ -5566,7 +5581,12 @@ op_addsub(
55665581

55675582
if (u_save((linenr_T)(oap->start.lnum - 1),
55685583
(linenr_T)(oap->end.lnum + 1)) == FAIL)
5584+
{
5585+
#ifdef FEAT_FOLDING
5586+
disable_fold_update--;
5587+
#endif
55695588
return;
5589+
}
55705590

55715591
pos = oap->start;
55725592
for (; pos.lnum <= oap->end.lnum; ++pos.lnum)
@@ -5624,6 +5644,10 @@ op_addsub(
56245644
if (g_cmd && one_change)
56255645
amount += Prenum1;
56265646
}
5647+
5648+
#ifdef FEAT_FOLDING
5649+
disable_fold_update--;
5650+
#endif
56275651
if (change_cnt)
56285652
changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L);
56295653

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ static char *(features[]) =
792792

793793
static int included_patches[] =
794794
{ /* Add new patch number below this line */
795+
/**/
796+
535,
795797
/**/
796798
534,
797799
/**/

0 commit comments

Comments
 (0)