patch 9.1.1877: cindent: wrong indentation after an array declaration

Commit: 
https://github.com/vim/vim/commit/61ef8a3db927162854c8a208ec603f55a6cd6449
Author: Anttoni Erkkilä <[email protected]>
Date:   Sun Oct 26 19:46:38 2025 +0000

    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]>

diff --git a/src/cindent.c b/src/cindent.c
index f2f2ac0c1..e23f96d45 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 d27adbc4b..589fcdd61 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 0ce44e9d4..13aa6ec43 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1vD6uM-004Bbu-9B%40256bit.org.

Raspunde prin e-mail lui