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.
This commit is contained in:
Yuan Fu 2023-02-05 15:20:52 -08:00
parent 2ac8c4bbd6
commit d68ff6016d
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 13 additions and 0 deletions

View 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)))))))

View 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)
=-=