summaryrefslogtreecommitdiffstats
path: root/src/fold.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fold.c')
-rw-r--r--src/fold.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/fold.c b/src/fold.c
index 2cd4dcd..3353cc5 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -1492,6 +1492,9 @@ deleteFoldRecurse(garray_T *gap)
// foldMarkAdjust() {{{2
/*
* Update line numbers of folds for inserted/deleted lines.
+ *
+ * We are adjusting the folds in the range from line1 til line2,
+ * make sure that line2 does not get smaller than line1
*/
void
foldMarkAdjust(
@@ -1505,6 +1508,8 @@ foldMarkAdjust(
// lines, set line2 so that only deleted lines have their folds removed.
if (amount == MAXLNUM && line2 >= line1 && line2 - line1 >= -amount_after)
line2 = line1 - amount_after - 1;
+ if (line2 < line1)
+ line2 = line1;
// If appending a line in Insert mode, it should be included in the fold
// just above the line.
if ((State & MODE_INSERT) && amount == (linenr_T)1 && line2 == MAXLNUM)