Skip to content

Commit 61ef8a3

Browse files
aerkkilachrisbra
authored andcommitted
patch 9.1.1877: cindent: wrong indentation after an array declaration
Problem: cindent: wrong indentation after an array declaration Solution: check if the filetype if javascript before matching the syntax (Anttoni Erkkilä) cindent matches a javascript syntax for C files causing wrong indentation in the following case: ``` void foo() { float a[5], b; } ``` closes: #18631 Signed-off-by: Anttoni Erkkilä <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent c8eeda9 commit 61ef8a3

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/cindent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3476,7 +3476,7 @@ get_c_indent(void)
34763476
amount = cur_amount;
34773477

34783478
n = (int)STRLEN(l);
3479-
if (terminated == ',' && (*skipwhite(l) == ']'
3479+
if (curbuf->b_ind_js && terminated == ',' && (*skipwhite(l) == ']'
34803480
|| (n >=2 && l[n - 2] == ']')))
34813481
break;
34823482

src/testdir/test_cindent.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,11 @@ def Test_cindent_1()
11061106
}
11071107
}
11081108

1109+
void foo() {
1110+
float a[5],
1111+
b;
1112+
}
1113+
11091114
/* end of AUTO */
11101115
[CODE]
11111116

@@ -2083,6 +2088,11 @@ def Test_cindent_1()
20832088
}
20842089
}
20852090

2091+
void foo() {
2092+
float a[5],
2093+
b;
2094+
}
2095+
20862096
/* end of AUTO */
20872097

20882098
[CODE]

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,8 @@ static char *(features[]) =
729729

730730
static int included_patches[] =
731731
{ /* Add new patch number below this line */
732+
/**/
733+
1877,
732734
/**/
733735
1876,
734736
/**/

0 commit comments

Comments
 (0)