summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2011-11-30 17:20:23 +0100
committerBram Moolenaar <bram@vim.org>2011-11-30 17:20:23 +0100
commit18f08c3b3f23531e0d627acf0e61505b0da74a8e (patch)
tree9c3bf014ae2481f9d352994484c24ece8243f86b
parent0f5ebb05682feba269e47410ed0a68fa77cc3af8 (diff)
downloadvim-18f08c3b3f23531e0d627acf0e61505b0da74a8e.tar.gz
updated for version 7.3.363v7.3.363v7-3-363
Problem: C indenting is wrong after #endif followed by a semicolon. Solution: Add special handling for a semicolon in a line by itself. (Lech Lorens)
-rw-r--r--src/misc1.c23
-rw-r--r--src/testdir/test3.in10
-rw-r--r--src/testdir/test3.ok10
-rw-r--r--src/version.c2
4 files changed, 45 insertions, 0 deletions
diff --git a/src/misc1.c b/src/misc1.c
index d260b0c2..11a1f94f 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -8143,6 +8143,29 @@ term_again:
break;
/*
+ * Find a line only has a semicolon that belongs to a previous
+ * line ending in '}', e.g. before an #endif. Don't increase
+ * indent then.
+ */
+ if (*(look = skipwhite(l)) == ';' && cin_nocode(look + 1))
+ {
+ pos_T curpos_save = curwin->w_cursor;
+
+ while (curwin->w_cursor.lnum > 1)
+ {
+ look = ml_get(--curwin->w_cursor.lnum);
+ if (!(cin_nocode(look) || cin_ispreproc_cont(
+ &look, &curwin->w_cursor.lnum)))
+ break;
+ }
+ if (curwin->w_cursor.lnum > 0
+ && cin_ends_in(look, (char_u *)"}", NULL))
+ break;
+
+ curwin->w_cursor = curpos_save;
+ }
+
+ /*
* If the PREVIOUS line is a function declaration, the current
* line (and the ones that follow) needs to be indented as
* parameters.
diff --git a/src/testdir/test3.in b/src/testdir/test3.in
index f987478f..d3911427 100644
--- a/src/testdir/test3.in
+++ b/src/testdir/test3.in
@@ -1454,6 +1454,16 @@ void func2(void)
printf("This line used to be indented incorrectly.\n");
}
+int foo[]
+#ifdef BAR
+
+= { 1, 2, 3,
+ 4, 5, 6 }
+
+#endif
+;
+ int baz;
+
void func3(void)
{
int tab[] = {
diff --git a/src/testdir/test3.ok b/src/testdir/test3.ok
index c95b1884..3c073664 100644
--- a/src/testdir/test3.ok
+++ b/src/testdir/test3.ok
@@ -1307,6 +1307,16 @@ void func2(void)
printf("This line used to be indented incorrectly.\n");
}
+int foo[]
+#ifdef BAR
+
+= { 1, 2, 3,
+ 4, 5, 6 }
+
+#endif
+ ;
+int baz;
+
void func3(void)
{
int tab[] = {
diff --git a/src/version.c b/src/version.c
index 99d6a79a..4719ffc5 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 363,
+/**/
362,
/**/
361,