Fix indentation for else clause in c-ts-mode (bug#67417)
* lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Add indentation for children of else_clause. * test/lisp/progmodes/c-ts-mode-resources/indent.erts: (Name): Add test for else-break. Also make the test such that it needs to indent correctly from scratch (rather than maintaining the already correct indentation.)
This commit is contained in:
parent
bf0b0c9c73
commit
f8d9dc26c7
2 changed files with 21 additions and 0 deletions
|
@ -452,6 +452,7 @@ MODE is either `c' or `cpp'."
|
|||
;; These rules are for cases where the body is bracketless.
|
||||
;; Tested by the "Bracketless Simple Statement" test.
|
||||
((parent-is "if_statement") standalone-parent c-ts-mode-indent-offset)
|
||||
((parent-is "else_clause") standalone-parent c-ts-mode-indent-offset)
|
||||
((parent-is "for_statement") standalone-parent c-ts-mode-indent-offset)
|
||||
((parent-is "while_statement") standalone-parent c-ts-mode-indent-offset)
|
||||
((parent-is "do_statement") standalone-parent c-ts-mode-indent-offset)
|
||||
|
|
|
@ -149,6 +149,21 @@ for (int i = 0;
|
|||
|
||||
Name: Bracketless Simple Statement
|
||||
|
||||
=-=
|
||||
for (int i = 0; i < 5; i++)
|
||||
continue;
|
||||
|
||||
while (true)
|
||||
return 1;
|
||||
|
||||
do
|
||||
i++;
|
||||
while (true)
|
||||
|
||||
if (true)
|
||||
break;
|
||||
else
|
||||
break;
|
||||
=-=
|
||||
for (int i = 0; i < 5; i++)
|
||||
continue;
|
||||
|
@ -159,6 +174,11 @@ while (true)
|
|||
do
|
||||
i++;
|
||||
while (true)
|
||||
|
||||
if (true)
|
||||
break;
|
||||
else
|
||||
break;
|
||||
=-=-=
|
||||
|
||||
Name: Nested If-Else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue