mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-30 12:07:46 +00:00
feat: simplify parens
This commit is contained in:
parent
0b480bc36d
commit
44affb27f5
3 changed files with 17 additions and 0 deletions
|
@ -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();
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
rec /**/ {
|
||||
|
||||
a = (((4)));
|
||||
|
||||
a = {a = 1 ;};
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
rec
|
||||
/**/
|
||||
{
|
||||
a = 4;
|
||||
|
||||
a = {a = 1;};
|
||||
|
||||
b = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue