1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-08-01 04:57:44 +00:00

feat: case expression

This commit is contained in:
Kevin Amado 2022-01-30 23:55:55 -05:00
parent 658f5e25db
commit 0f5e67f509
No known key found for this signature in database
GPG key ID: FFF341057F503148
3 changed files with 37 additions and 0 deletions

View file

@ -41,6 +41,13 @@ pub fn rule(
steps.push_back(crate::builder::Step::FormatWider( steps.push_back(crate::builder::Step::FormatWider(
child.element, child.element,
)); ));
} else if branch == "else"
&& child.element.kind() == rnix::SyntaxKind::NODE_IF_ELSE
{
steps.push_back(crate::builder::Step::Whitespace);
steps.push_back(crate::builder::Step::FormatWider(
child.element,
));
} else { } else {
steps.push_back(crate::builder::Step::Indent); steps.push_back(crate::builder::Step::Indent);
steps.push_back(crate::builder::Step::NewLine); steps.push_back(crate::builder::Step::NewLine);

View file

@ -1,6 +1,8 @@
[ [
(if ./a then b else c) (if ./a then b else c)
(if /**/ a /**/ then /**/ b /**/ else /**/ c) (if /**/ a /**/ then /**/ b /**/ else /**/ c)
(if if a then b else c then b else if a then b else if a then b else c)
(if if a then b else c then b else if a then b else /*x*/ if a then b else c)
(if (if
(if (if
(if (if

View file

@ -17,6 +17,34 @@
/**/ /**/
c c
) )
(
if
if a
then b
else c
then b
else if a
then b
else if a
then b
else c
)
(
if
if a
then b
else c
then b
else if a
then b
else
/*
x
*/
if a
then b
else c
)
( (
if if
( (