]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix c-ts-mode indentation (bug#61291)
authorYuan Fu <casouri@gmail.com>
Sun, 5 Feb 2023 23:20:52 +0000 (15:20 -0800)
committerYuan Fu <casouri@gmail.com>
Tue, 7 Feb 2023 02:28:39 +0000 (18:28 -0800)
Fix indentation for the semicolon in

while (str_a[i++] == str_b[j++])
  ;

* lisp/progmodes/c-ts-mode.el (c-ts-mode--indent-styles): New rule.
* test/lisp/progmodes/c-ts-mode-resources/indent.erts: New test.

lisp/progmodes/c-ts-mode.el
test/lisp/progmodes/c-ts-mode-resources/indent.erts

index 9381608166690437db856d66449a6e561059fad3..1737b8c5715f723acd63ee3c8e05eab7787e993d 100644 (file)
@@ -285,6 +285,8 @@ MODE is either `c' or `cpp'."
            ((node-is "}") point-min c-ts-common-statement-offset)
            ;; Opening bracket.
            ((node-is "compound_statement") point-min c-ts-common-statement-offset)
+           ;; Bug#61291.
+           ((match "expression_statement" nil "body") point-min c-ts-common-statement-offset)
 
            ,@(when (eq mode 'cpp)
                `(((node-is "field_initializer_list") parent-bol ,(* c-ts-mode-indent-offset 2)))))))
index 6f64e1e7953823800138afe2bc4d508a49a09de8..2750526f893069e8464017cecdf12b6e91305c28 100644 (file)
@@ -144,6 +144,17 @@ int f2(int x,
 };
 =-=-=
 
+Name: Semi-colon in While Loop (bug#61291)
+
+=-=
+while (true)
+  ;
+for (int i = 0;
+     i < 5;
+     i++)
+  ;
+=-=-=
+
 Name: Multiline Block Comments 1 (bug#60270)
 
 =-=