diff options
author | vimboss <devnull@localhost> | 2009-11-03 13:46:54 +0000 |
---|---|---|
committer | vimboss <devnull@localhost> | 2009-11-03 13:46:54 +0000 |
commit | 5e957ee295fc4d8aef6d39345e97828ba3aa2a90 (patch) | |
tree | 77d76919c1b8956900da393037b1aa17c6478336 | |
parent | 9fd6fe5c2ea383d00197de656755bab0e2ba3f71 (diff) | |
download | vim-5e957ee295fc4d8aef6d39345e97828ba3aa2a90.tar.gz |
-rw-r--r-- | src/fold.c | 34 | ||||
-rw-r--r-- | src/testdir/test45.in | 7 | ||||
-rw-r--r-- | src/testdir/test45.ok | 3 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 44 insertions, 2 deletions
@@ -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. */ diff --git a/src/testdir/test45.in b/src/testdir/test45.in index cc991497..1dfad545 100644 --- a/src/testdir/test45.in +++ b/src/testdir/test45.in @@ -28,9 +28,14 @@ i jI :call append("$", "indent " . foldlevel(".")) k:call append("$", foldlevel(".")) :" test syntax folding :set fdm=syntax fdl=0 -:syn region Hup start="dd" end="hh" fold +:syn region Hup start="dd" end="ii" fold contains=Fd1,Fd2,Fd3 +:syn region Fd1 start="ee" end="ff" fold contained +:syn region Fd2 start="gg" end="hh" fold contained +:syn region Fd3 start="commentstart" end="commentend" fold contained Gzk:call append("$", "folding " . getline(".")) k:call append("$", getline(".")) +jAcommentstart Acommentend:set fdl=1 +3j:call append("$", getline(".")) :" test expression folding :fun Flvl() let l = getline(v:lnum) diff --git a/src/testdir/test45.ok b/src/testdir/test45.ok index f5a1380e..713cf882 100644 --- a/src/testdir/test45.ok +++ b/src/testdir/test45.ok @@ -8,8 +8,9 @@ marker 2 0 indent 2 1 -folding 8 hh +folding 9 ii 3 cc +7 gg expr 2 1 2 diff --git a/src/version.c b/src/version.c index 3c38d229..9f0ec933 100644 --- a/src/version.c +++ b/src/version.c @@ -677,6 +677,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 274, +/**/ 273, /**/ 272, |