]> git.pld-linux.org Git - packages/vim.git/blob - 7.3.195
- new: 7.3.264
[packages/vim.git] / 7.3.195
1 To: vim_dev@googlegroups.com
2 Subject: Patch 7.3.195
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 7.3.195
11 Problem:    "} else" causes following lines to be indented too much. (Rouben
12             Rostamian)
13 Solution:   Better detection for the "else". (Lech Lorens)
14 Files:      src/misc1.c, src/testdir/test3.in, src/testdir/test3.ok
15
16
17 *** ../vim-7.3.194/src/misc1.c  2011-05-10 16:41:13.000000000 +0200
18 --- src/misc1.c 2011-05-19 16:30:28.000000000 +0200
19 ***************
20 *** 5482,5489 ****
21    * Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
22    * '}'.
23    * Don't consider "} else" a terminated line.
24 !  * Don't consider a line where there are unmatched opening braces before '}',
25 !  * ';' or ',' a terminated line.
26    * Return the character terminating the line (ending char's have precedence if
27    * both apply in order to determine initializations).
28    */
29 --- 5482,5489 ----
30    * Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
31    * '}'.
32    * Don't consider "} else" a terminated line.
33 !  * If a line begins with an "else", only consider it terminated if no unmatched
34 !  * opening braces follow (handle "else { foo();" correctly).
35    * Return the character terminating the line (ending char's have precedence if
36    * both apply in order to determine initializations).
37    */
38 ***************
39 *** 5493,5513 ****
40       int               incl_open;      /* include '{' at the end as terminator */
41       int               incl_comma;     /* recognize a trailing comma */
42   {
43 !     char_u found_start = 0;
44 !     unsigned n_open = 0;
45   
46       s = cin_skipcomment(s);
47   
48       if (*s == '{' || (*s == '}' && !cin_iselse(s)))
49         found_start = *s;
50   
51       while (*s)
52       {
53         /* skip over comments, "" strings and 'c'haracters */
54         s = skip_string(cin_skipcomment(s));
55         if (*s == '}' && n_open > 0)
56             --n_open;
57 !       if (n_open == 0
58                 && (*s == ';' || *s == '}' || (incl_comma && *s == ','))
59                 && cin_nocode(s + 1))
60             return *s;
61 --- 5493,5517 ----
62       int               incl_open;      /* include '{' at the end as terminator */
63       int               incl_comma;     /* recognize a trailing comma */
64   {
65 !     char_u    found_start = 0;
66 !     unsigned  n_open = 0;
67 !     int               is_else = FALSE;
68   
69       s = cin_skipcomment(s);
70   
71       if (*s == '{' || (*s == '}' && !cin_iselse(s)))
72         found_start = *s;
73   
74 +     if (!found_start)
75 +       is_else = cin_iselse(s);
76
77       while (*s)
78       {
79         /* skip over comments, "" strings and 'c'haracters */
80         s = skip_string(cin_skipcomment(s));
81         if (*s == '}' && n_open > 0)
82             --n_open;
83 !       if ((!is_else || n_open == 0)
84                 && (*s == ';' || *s == '}' || (incl_comma && *s == ','))
85                 && cin_nocode(s + 1))
86             return *s;
87 *** ../vim-7.3.194/src/testdir/test3.in 2011-05-10 13:38:23.000000000 +0200
88 --- src/testdir/test3.in        2011-05-19 16:29:01.000000000 +0200
89 ***************
90 *** 1345,1351 ****
91   
92   STARTTEST
93   :set cino&
94 ! 2kdd=][
95   ENDTEST
96   
97   void func(void)
98 --- 1345,1351 ----
99   
100   STARTTEST
101   :set cino&
102 ! 2kdd=4][
103   ENDTEST
104   
105   void func(void)
106 ***************
107 *** 1359,1364 ****
108 --- 1359,1392 ----
109         printf("Foo!\n");
110   }
111   
112 + void func1(void)
113 + {
114 +       char* tab[] = {"foo", "bar",
115 +               "baz", "quux",
116 +                       "this line used", "to be indented incorrectly"};
117 +       foo();
118 + }
119
120 + void func2(void)
121 + {
122 +       int tab[] =
123 +       {1, 2,
124 +               3, 4,
125 +               5, 6};
126
127 +               printf("This line used to be indented incorrectly.\n");
128 + }
129
130 + void func3(void)
131 + {
132 +       int tab[] = {
133 +       1, 2,
134 +       3, 4,
135 +       5, 6};
136
137 + printf("Don't you dare indent this line incorrectly!\n);
138 + }
139
140   STARTTEST
141   :set cino&
142   2kdd=][
143 *** ../vim-7.3.194/src/testdir/test3.ok 2011-05-10 13:38:23.000000000 +0200
144 --- src/testdir/test3.ok        2011-05-19 16:29:01.000000000 +0200
145 ***************
146 *** 1216,1221 ****
147 --- 1216,1249 ----
148         printf("Foo!\n");
149   }
150   
151 + void func1(void)
152 + {
153 +       char* tab[] = {"foo", "bar",
154 +               "baz", "quux",
155 +               "this line used", "to be indented incorrectly"};
156 +       foo();
157 + }
158
159 + void func2(void)
160 + {
161 +       int tab[] =
162 +       {1, 2,
163 +               3, 4,
164 +               5, 6};
165
166 +       printf("This line used to be indented incorrectly.\n");
167 + }
168
169 + void func3(void)
170 + {
171 +       int tab[] = {
172 +               1, 2,
173 +               3, 4,
174 +               5, 6};
175
176 +       printf("Don't you dare indent this line incorrectly!\n);
177 + }
178
179   
180   void func(void)
181   {
182 *** ../vim-7.3.194/src/version.c        2011-05-19 14:59:07.000000000 +0200
183 --- src/version.c       2011-05-19 16:34:16.000000000 +0200
184 ***************
185 *** 711,712 ****
186 --- 711,714 ----
187   {   /* Add new patch number below this line */
188 + /**/
189 +     195,
190   /**/
191
192 -- 
193 I AM THANKFUL...
194 ...for the taxes that I pay because it means that I am employed.
195
196  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
197 ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
198 \\\  an exciting new programming language -- http://www.Zimbu.org        ///
199  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
This page took 0.040122 seconds and 3 git commands to generate.