1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-07-30 12:07:46 +00:00

feat: simplify parens

This commit is contained in:
Kevin Amado 2022-02-28 17:47:26 -05:00
parent 0b480bc36d
commit 44affb27f5
3 changed files with 17 additions and 0 deletions

View file

@ -55,6 +55,19 @@ pub(crate) fn rule(
// peek: expr
let child_expr = children.get_next().unwrap();
let child_expr =
if matches!(child_expr.kind(), rnix::SyntaxKind::NODE_PAREN) {
let mut children: Vec<rnix::SyntaxElement> =
child_expr.as_node().unwrap().children_with_tokens().collect();
if children.len() == 3 {
children.swap_remove(1)
} else {
child_expr
}
} else {
child_expr
};
// peek: /**/
let mut comments_after = std::collections::LinkedList::new();

View file

@ -1,5 +1,7 @@
rec /**/ {
a = (((4)));
a = {a = 1 ;};

View file

@ -1,6 +1,8 @@
rec
/**/
{
a = 4;
a = {a = 1;};
b = {