diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el index 1737b8c5715..f2d5a482009 100644 --- a/lisp/progmodes/c-ts-mode.el +++ b/lisp/progmodes/c-ts-mode.el @@ -287,6 +287,12 @@ MODE is either `c' or `cpp'." ((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) + ;; These rules are for cases where the body is bracketless. + ;; Tested by the "Bracketless Simple Statement" test. + ((parent-is "if_statement") point-min c-ts-common-statement-offset) + ((parent-is "for_statement") point-min c-ts-common-statement-offset) + ((parent-is "while_statement") point-min c-ts-common-statement-offset) + ((parent-is "do_statement") 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 2750526f893..8c588f56f9a 100644 --- a/test/lisp/progmodes/c-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/c-ts-mode-resources/indent.erts @@ -155,6 +155,20 @@ for (int i = 0; ; =-=-= +Name: Bracketless Simple Statement + +=-= +for (int i = 0; i < 5; i++) + continue; + +while (true) + return 1; + +do + i++; +while (true) +=-=-= + Name: Multiline Block Comments 1 (bug#60270) =-=