vim-patch:9.1.1877: cindent: wrong indentation after an array declaration (#36340)

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: vim/vim#18631

https://github.com/vim/vim/commit/61ef8a3db927162854c8a208ec603f55a6cd6449

Co-authored-by: Anttoni Erkkilä <anttoni.erkkila@protonmail.com>
This commit is contained in:
zeertzjqandAnttoni Erkkilä authored and GitHub committed 2025-10-27 00:06:25 +00:00
1 parent d707ccf988
commit f0cf488698
2 files changed
+12 -3

No files matched your search

+2 -3
View File
@@ -3179,9 +3179,8 @@ int get_c_indent(void)
amount = cur_amount;
n = (int)strlen(l);
if (terminated == ','
&& (*skipwhite(l) == ']'
|| (n >= 2 && l[n - 2] == ']'))) {
if (curbuf->b_ind_js && terminated == ','
&& (*skipwhite(l) == ']' || (n >= 2 && l[n - 2] == ']'))) {
break;
}
+10
View File
@@ -1101,6 +1101,11 @@ func Test_cindent_1()
}
}
void foo() {
float a[5],
b;
}
/* end of AUTO */
[CODE]
@@ -2078,6 +2083,11 @@ func Test_cindent_1()
}
}
void foo() {
float a[5],
b;
}
/* end of AUTO */
[CODE]