From d68ff6016d0ca011b5bf0fd05578fe1abb2e53a9 Mon Sep 17 00:00:00 2001 From: Yuan Fu <casouri@gmail.com> Date: Sun, 5 Feb 2023 15:20:52 -0800 Subject: [PATCH] Fix c-ts-mode indentation (bug#61291) 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 | 2 ++ test/lisp/progmodes/c-ts-mode-resources/indent.erts | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 93816081666..1737b8c5715 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -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))))))) diff --git a/test/lisp/progmodes/c-ts-mode-resources/indent.erts b/test/lisp/progmodes/c-ts-mode-resources/indent.erts index 6f64e1e7953..2750526f893 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts @@ -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) =-= -- 2.39.5