summaryrefslogtreecommitdiffstats
path: root/src/fold.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2009-11-03 13:46:54 +0000
committerBram Moolenaar <Bram@vim.org>2009-11-03 13:46:54 +0000
commitec98647b1c674686778f3ab445581115a744afcd (patch)
tree77d76919c1b8956900da393037b1aa17c6478336 /src/fold.c
parent2f59b5c1cc6fe153469ad1b4f13ae3fce8825f4f (diff)
updated for version 7.2-274v7.2.274
Diffstat (limited to 'src/fold.c')
-rw-r--r--src/fold.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/fold.c b/src/fold.c
index a127bf67cc..f3be3788d3 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -2256,6 +2256,40 @@ foldUpdateIEMS(wp, top, bot)
}
}
+ /*
+ * If folding is defined by the syntax, it is possible that a change in
+ * one line will cause all sub-folds of the current fold to change (e.g.,
+ * closing a C-style comment can cause folds in the subsequent lines to
+ * appear). To take that into account we should adjust the value of "bot"
+ * to point to the end of the current fold:
+ */
+ if (foldlevelSyntax == getlevel)
+ {
+ garray_T *gap = &wp->w_folds;
+ fold_T *fp = NULL;
+ int current_fdl = 0;
+ linenr_T fold_start_lnum = 0;
+ linenr_T lnum_rel = fline.lnum;
+
+ while (current_fdl < fline.lvl)
+ {
+ if (!foldFind(gap, lnum_rel, &fp))
+ break;
+ ++current_fdl;
+
+ fold_start_lnum += fp->fd_top;
+ gap = &fp->fd_nested;
+ lnum_rel -= fp->fd_top;
+ }
+ if (fp != NULL && current_fdl == fline.lvl)
+ {
+ linenr_T fold_end_lnum = fold_start_lnum + fp->fd_len;
+
+ if (fold_end_lnum > bot)
+ bot = fold_end_lnum;
+ }
+ }
+
start = fline.lnum;
end = bot;
/* Do at least one line. */