Vim, when 'cino' is set to "(0,ts", will incorrectly indent 
the following function:
#v+
static
void func(int a
#if defined(FOO)
        , int b
        , int c
#endif
        )
{
}
#v-

in the following way:

#v+
static
        void func(int a
#if defined(FOO)
                  , int b
                  , int c
#endif
                 )
{
}
#v-

while it should as follows:

#v+
static
void func(int a
#if defined(FOO)
          , int b
          , int c
#endif
         )
{
}
#v-

The attached patch fixes the problem and adds a test.

-- 
Cheers,
Lech

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/misc1.c b/src/misc1.c
index f09a5bd..fae067d 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -5513,6 +5513,16 @@ cin_isfuncdecl(sp, first_lnum)
     else
 	s = *sp;
 
+    /* Make sure we don't mistake a preprocessor directive for a function
+     * declaration. E.g.
+     * #if defined(FOO_BAR)
+     * looks a little bit like a function declaration.
+     */
+    while (vim_isspace(*s))
+	++s;
+    if ('#' == *s)
+	return FALSE;
+
     while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
     {
 	if (cin_iscomment(s))	/* ignore comments */
diff --git a/src/testdir/test3.in b/src/testdir/test3.in
index 35582bd..1e7f22c 100644
--- a/src/testdir/test3.in
+++ b/src/testdir/test3.in
@@ -1315,6 +1315,20 @@ int main ()
 }
 
 STARTTEST
+:set cino=(0,ts
+2kdd=][
+ENDTEST
+
+void func(int a
+#if defined(FOO)
+		  , int b
+		  , int c
+#endif
+		 )
+{
+}
+
+STARTTEST
 :g/^STARTTEST/.,/^ENDTEST/d
 :1;/start of AUTO/,$wq! test.out
 ENDTEST
diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok
index 8c015a3..934914e 100644
--- a/src/testdir/test3.ok
+++ b/src/testdir/test3.ok
@@ -1183,3 +1183,13 @@ int main ()
 		foo;
 }
 
+
+void func(int a
+#if defined(FOO)
+		  , int b
+		  , int c
+#endif
+		 )
+{
+}
+

Raspunde prin e-mail lui