From f0cf4886981eb2d690d6d8f7c70e432f1c2280ee Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Oct 2025 08:06:25 +0800 Subject: [PATCH] vim-patch:9.1.1877: cindent: wrong indentation after an array declaration (#36340) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ä --- src/nvim/indent_c.c | 5 ++--- test/old/testdir/test_cindent.vim | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index d197e78187..fa85a0de47 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -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; } diff --git a/test/old/testdir/test_cindent.vim b/test/old/testdir/test_cindent.vim index d9702f57d2..170da533d1 100644 --- a/test/old/testdir/test_cindent.vim +++ b/test/old/testdir/test_cindent.vim @@ -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]