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

feat: increase paren coverage

This commit is contained in:
Kevin Amado 2022-01-29 18:16:22 -05:00
parent 56ed74357c
commit 5ffcf04579
No known key found for this signature in database
GPG key ID: FFF341057F503148
3 changed files with 194 additions and 19 deletions

View file

@ -12,41 +12,45 @@ pub fn rule(
build_ctx.config.layout()
};
// (
let child = children.get_next().unwrap();
steps.push_back(crate::builder::Step::Format(child.element));
match layout {
crate::config::Layout::Tall => {
steps.push_back(crate::builder::Step::Indent);
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
}
crate::config::Layout::Wide => {
steps.push_back(crate::builder::Step::Whitespace);
}
crate::config::Layout::Wide => {}
}
// /**/
children.drain_comments(|text| {
steps.push_back(crate::builder::Step::Comment(text));
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text));
});
// expr
let child = children.get_next().unwrap();
match layout {
crate::config::Layout::Tall => {
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::FormatWider(child.element));
}
crate::config::Layout::Wide => {
steps.push_back(crate::builder::Step::Whitespace);
steps.push_back(crate::builder::Step::Format(child.element));
}
}
// /**/
children.drain_comments(|text| {
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
steps.push_back(crate::builder::Step::Comment(text));
});
// )
let child = children.get_next().unwrap();
match layout {
crate::config::Layout::Tall => {

View file

@ -1 +1,18 @@
(/*a*/(/*b*/(c))/*d*/)
(
( ( c ) )
( ( c )/*e*/)
( ( c/*d*/) )
( ( c/*d*/)/*e*/)
( (/*b*/c ) )
( (/*b*/c )/*e*/)
( (/*b*/c/*d*/) )
( (/*b*/c/*d*/)/*e*/)
(/*a*/( c ) )
(/*a*/( c )/*e*/)
(/*a*/( c/*d*/) )
(/*a*/( c/*d*/)/*e*/)
(/*a*/(/*b*/c ) )
(/*a*/(/*b*/c )/*e*/)
(/*a*/(/*b*/c/*d*/) )
(/*a*/(/*b*/c/*d*/)/*e*/)
)

View file

@ -1,14 +1,168 @@
(
/*
a
*/
(
/*
b
*/
( c )
)
/*
d
*/
( ( c ) )
(
( c )
/*
e
*/
)
(
(
c
/*
d
*/
)
)
(
(
c
/*
d
*/
)
/*
e
*/
)
(
(
/*
b
*/
c
)
)
(
(
/*
b
*/
c
)
/*
e
*/
)
(
(
/*
b
*/
c
/*
d
*/
)
)
(
(
/*
b
*/
c
/*
d
*/
)
/*
e
*/
)
(
/*
a
*/
( c )
)
(
/*
a
*/
( c )
/*
e
*/
)
(
/*
a
*/
(
c
/*
d
*/
)
)
(
/*
a
*/
(
c
/*
d
*/
)
/*
e
*/
)
(
/*
a
*/
(
/*
b
*/
c
)
)
(
/*
a
*/
(
/*
b
*/
c
)
/*
e
*/
)
(
/*
a
*/
(
/*
b
*/
c
/*
d
*/
)
)
(
/*
a
*/
(
/*
b
*/
c
/*
d
*/
)
/*
e
*/
)
)