summaryrefslogtreecommitdiff
path: root/source/ap/vim/patches/7.2.274
blob: 809cedcf624c9cf4291143d161ef59ef490d584a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
To: vim-dev@vim.org
Subject: Patch 7.2.274
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.2.274
Problem:    Syntax folding doesn't work properly when adding a comment.
Solution:   Fix it and add a test. (Lech Lorens)
Files:	    src/fold.c, src/testdir/test45.in, src/testdir/test45.ok


*** ../vim-7.2.273/src/fold.c	2009-09-18 15:16:37.000000000 +0200
--- src/fold.c	2009-11-03 12:36:37.000000000 +0100
***************
*** 2256,2261 ****
--- 2256,2295 ----
  	}
      }
  
+     /*
+      * 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. */
*** ../vim-7.2.273/src/testdir/test45.in	2007-09-25 17:58:43.000000000 +0200
--- src/testdir/test45.in	2009-11-03 12:22:38.000000000 +0100
***************
*** 28,36 ****
  k:call append("$", foldlevel("."))
  :" test syntax folding
  :set fdm=syntax fdl=0
! :syn region Hup start="dd" end="hh" fold
  Gzk:call append("$", "folding " . getline("."))
  k:call append("$", getline("."))
  :" test expression folding
  :fun Flvl()
    let l = getline(v:lnum)
--- 28,41 ----
  k:call append("$", foldlevel("."))
  :" test syntax folding
  :set fdm=syntax fdl=0
! :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)
*** ../vim-7.2.273/src/testdir/test45.ok	2004-06-13 17:47:37.000000000 +0200
--- src/testdir/test45.ok	2009-11-03 12:22:50.000000000 +0100
***************
*** 8,15 ****
  0
  indent 2
  1
! folding 8 hh
      3 cc
  expr 2
  1
  2
--- 8,16 ----
  0
  indent 2
  1
! folding 9 ii
      3 cc
+ 7 gg
  expr 2
  1
  2
*** ../vim-7.2.273/src/version.c	2009-11-03 14:26:29.000000000 +0100
--- src/version.c	2009-11-03 14:44:21.000000000 +0100
***************
*** 678,679 ****
--- 678,681 ----
  {   /* Add new patch number below this line */
+ /**/
+     274,
  /**/

-- 
BRIDGEKEEPER: What is your favorite colour?
LAUNCELOT:    Blue.
BRIDGEKEEPER: Right.  Off you go.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///