]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.195 v7.3.195
authorBram Moolenaar <Bram@vim.org>
Thu, 19 May 2011 14:35:09 +0000 (16:35 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 19 May 2011 14:35:09 +0000 (16:35 +0200)
Problem:    "} else" causes following lines to be indented too much. (Rouben
            Rostamian)
Solution:   Better detection for the "else". (Lech Lorens)

src/misc1.c
src/testdir/test3.in
src/testdir/test3.ok
src/version.c

index f1ab84879c22c0c639f0cc2a918d321c7d8eabb6..0959e2a243907f59c0e64476cc0c48a60654e6d2 100644 (file)
@@ -5482,8 +5482,8 @@ cin_islinecomment(p)
  * Recognize a line that starts with '{' or '}', or ends with ';', ',', '{' or
  * '}'.
  * Don't consider "} else" a terminated line.
- * Don't consider a line where there are unmatched opening braces before '}',
- * ';' or ',' a terminated line.
+ * If a line begins with an "else", only consider it terminated if no unmatched
+ * opening braces follow (handle "else { foo();" correctly).
  * Return the character terminating the line (ending char's have precedence if
  * both apply in order to determine initializations).
  */
@@ -5493,21 +5493,25 @@ cin_isterminated(s, incl_open, incl_comma)
     int                incl_open;      /* include '{' at the end as terminator */
     int                incl_comma;     /* recognize a trailing comma */
 {
-    char_u found_start = 0;
-    unsigned n_open = 0;
+    char_u     found_start = 0;
+    unsigned   n_open = 0;
+    int                is_else = FALSE;
 
     s = cin_skipcomment(s);
 
     if (*s == '{' || (*s == '}' && !cin_iselse(s)))
        found_start = *s;
 
+    if (!found_start)
+       is_else = cin_iselse(s);
+
     while (*s)
     {
        /* skip over comments, "" strings and 'c'haracters */
        s = skip_string(cin_skipcomment(s));
        if (*s == '}' && n_open > 0)
            --n_open;
-       if (n_open == 0
+       if ((!is_else || n_open == 0)
                && (*s == ';' || *s == '}' || (incl_comma && *s == ','))
                && cin_nocode(s + 1))
            return *s;
index 56a1dc89478ab762403b295d08d1963c378442bf..05efa98486648727e5c0f8a7107943b8ba226dac 100644 (file)
@@ -1345,7 +1345,7 @@ func(int a
 
 STARTTEST
 :set cino&
-2kdd=][
+2kdd=4][
 ENDTEST
 
 void func(void)
@@ -1359,6 +1359,34 @@ void func(void)
        printf("Foo!\n");
 }
 
+void func1(void)
+{
+       char* tab[] = {"foo", "bar",
+               "baz", "quux",
+                       "this line used", "to be indented incorrectly"};
+       foo();
+}
+
+void func2(void)
+{
+       int tab[] =
+       {1, 2,
+               3, 4,
+               5, 6};
+
+               printf("This line used to be indented incorrectly.\n");
+}
+
+void func3(void)
+{
+       int tab[] = {
+       1, 2,
+       3, 4,
+       5, 6};
+
+printf("Don't you dare indent this line incorrectly!\n);
+}
+
 STARTTEST
 :set cino&
 2kdd=][
index 656b16ecb5549ab9d68e53d957f49f42b25b5aed..2e622728a46a547731ea424dd784674fd33135e1 100644 (file)
@@ -1216,6 +1216,34 @@ void func(void)
        printf("Foo!\n");
 }
 
+void func1(void)
+{
+       char* tab[] = {"foo", "bar",
+               "baz", "quux",
+               "this line used", "to be indented incorrectly"};
+       foo();
+}
+
+void func2(void)
+{
+       int tab[] =
+       {1, 2,
+               3, 4,
+               5, 6};
+
+       printf("This line used to be indented incorrectly.\n");
+}
+
+void func3(void)
+{
+       int tab[] = {
+               1, 2,
+               3, 4,
+               5, 6};
+
+       printf("Don't you dare indent this line incorrectly!\n);
+}
+
 
 void func(void)
 {
index b505c29466b2ebcfacdfa4ab1b6eed52223565ec..968bbb355b6be6c82c1c1acafa444ee07cda5d9e 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    195,
 /**/
     194,
 /**/