From: Anttoni Erkkilä Date: Sun, 26 Oct 2025 19:46:38 +0000 (+0000) Subject: patch 9.1.1877: cindent: wrong indentation after an array declaration X-Git-Tag: v9.1.1877^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=61ef8a3db927162854c8a208ec603f55a6cd6449;p=thirdparty%2Fvim.git 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ä Signed-off-by: Christian Brabandt --- diff --git a/src/cindent.c b/src/cindent.c index f2f2ac0c10..e23f96d453 100644 --- a/src/cindent.c +++ b/src/cindent.c @@ -3476,7 +3476,7 @@ get_c_indent(void) amount = cur_amount; n = (int)STRLEN(l); - if (terminated == ',' && (*skipwhite(l) == ']' + if (curbuf->b_ind_js && terminated == ',' && (*skipwhite(l) == ']' || (n >=2 && l[n - 2] == ']'))) break; diff --git a/src/testdir/test_cindent.vim b/src/testdir/test_cindent.vim index d27adbc4b5..589fcdd61f 100644 --- a/src/testdir/test_cindent.vim +++ b/src/testdir/test_cindent.vim @@ -1106,6 +1106,11 @@ def Test_cindent_1() } } + void foo() { + float a[5], + b; + } + /* end of AUTO */ [CODE] @@ -2083,6 +2088,11 @@ def Test_cindent_1() } } + void foo() { + float a[5], + b; + } + /* end of AUTO */ [CODE] diff --git a/src/version.c b/src/version.c index 0ce44e9d46..13aa6ec436 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1877, /**/ 1876, /**/