Fix c-ts-mode bracketless indentation for BSD style (bug#66152)
* lisp/progmodes/c-ts-mode.el: (c-ts-mode--indent-styles): Make sure the BSD rules only apply to opening bracket (compound_statement), then bracketless statements will fallback to common rules. * test/lisp/progmodes/c-ts-mode-resources/indent-bsd.erts: Copy the bracketless test from indent.erts to here.
This commit is contained in:
parent
e23068cb9a
commit
7f1bd69cd1
2 changed files with 41 additions and 7 deletions
|
@ -515,13 +515,13 @@ MODE is either `c' or `cpp'."
|
||||||
((node-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
|
((node-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
|
||||||
((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
|
((parent-is "labeled_statement") parent-bol c-ts-mode-indent-offset)
|
||||||
((parent-is "compound_statement") parent-bol c-ts-mode-indent-offset)
|
((parent-is "compound_statement") parent-bol c-ts-mode-indent-offset)
|
||||||
((parent-is "if_statement") parent-bol 0)
|
((match "compound_statement" "if_statement") standalone-parent 0)
|
||||||
((parent-is "else_clause") parent-bol 0)
|
((match "compound_statement" "else_clause") standalone-parent 0)
|
||||||
((parent-is "for_statement") parent-bol 0)
|
((match "compound_statement" "for_statement") standalone-parent 0)
|
||||||
((parent-is "while_statement") parent-bol 0)
|
((match "compound_statement" "while_statement") standalone-parent 0)
|
||||||
((parent-is "switch_statement") parent-bol 0)
|
((match "compound_statement" "switch_statement") standalone-parent 0)
|
||||||
((parent-is "case_statement") parent-bol 0)
|
((match "compound_statement" "case_statement") standalone-parent 0)
|
||||||
((parent-is "do_statement") parent-bol 0)
|
((match "compound_statement" "do_statement") standalone-parent 0)
|
||||||
,@common))))
|
,@common))))
|
||||||
|
|
||||||
(defun c-ts-mode--top-level-label-matcher (node parent &rest _)
|
(defun c-ts-mode--top-level-label-matcher (node parent &rest _)
|
||||||
|
|
|
@ -91,3 +91,37 @@ main (int argc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
=-=-=
|
=-=-=
|
||||||
|
|
||||||
|
Name: Bracketless Simple Statement (bug#66152)
|
||||||
|
|
||||||
|
=-=
|
||||||
|
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;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
do
|
||||||
|
i++;
|
||||||
|
while (true)
|
||||||
|
|
||||||
|
if (true)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
=-=-=
|
||||||
|
|
Loading…
Add table
Reference in a new issue