]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.201 v7.3.201
authorBram Moolenaar <Bram@vim.org>
Wed, 25 May 2011 11:34:04 +0000 (13:34 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 May 2011 11:34:04 +0000 (13:34 +0200)
Problem:    "} else" still causes following lines to be indented too much.
Solution:   Better detection for the "else" block. (Lech Lorens)

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

index 0959e2a243907f59c0e64476cc0c48a60654e6d2..0fc02ba9948257e2a21320bef1c40d3c0c0a9705 100644 (file)
@@ -7541,17 +7541,25 @@ get_c_indent()
 
                        /*
                         * When searching for a terminated line, don't use the
-                        * one between the "if" and the "else".
+                        * one between the "if" and the matching "else".
                         * Need to use the scope of this "else".  XXX
                         * If whilelevel != 0 continue looking for a "do {".
                         */
-                       if (cin_iselse(l)
-                               && whilelevel == 0
-                               && ((trypos = find_start_brace(ind_maxcomment))
-                                                                   == NULL
+                       if (cin_iselse(l) && whilelevel == 0)
+                       {
+                           /* If we're looking at "} else", let's make sure we
+                            * find the opening brace of the enclosing scope,
+                            * not the one from "if () {". */
+                           if (*l == '}')
+                               curwin->w_cursor.col =
+                                                  (l - ml_get_curline()) + 1;
+
+                           if ((trypos = find_start_brace(ind_maxcomment))
+                                                                      == NULL
                                    || find_match(LOOKFOR_IF, trypos->lnum,
-                                       ind_maxparen, ind_maxcomment) == FAIL))
-                           break;
+                                       ind_maxparen, ind_maxcomment) == FAIL)
+                               break;
+                       }
                    }
 
                    /*
index 05efa98486648727e5c0f8a7107943b8ba226dac..0d3720530da401d28c3e7c7e651d135a4bccc0ac 100644 (file)
@@ -1412,6 +1412,21 @@ void func(void)
         */
 }
 
+STARTTEST
+:set cino&
+2kdd=][
+ENDTEST
+
+void func(void)
+{
+       for (int i = 0; i < 10; ++i)
+               if (i & 1) {
+                       foo(1);
+               } else
+                       foo(0);
+baz();
+}
+
 STARTTEST
 :g/^STARTTEST/.,/^ENDTEST/d
 :1;/start of AUTO/,$wq! test.out
index 2e622728a46a547731ea424dd784674fd33135e1..852a4c59bd4393220c60c0cfc2431bc14f939cbd 100644 (file)
@@ -1262,3 +1262,14 @@ void func(void)
        foo();
 }
 
+
+void func(void)
+{
+       for (int i = 0; i < 10; ++i)
+               if (i & 1) {
+                       foo(1);
+               } else
+                       foo(0);
+       baz();
+}
+
index 14537c6f144fae0e2c7718c7496ee9008f42409f..64f49af8a5df07741a057d9a2d5c1925e92e599c 100644 (file)
@@ -709,6 +709,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    201,
 /**/
     200,
 /**/