mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 04:57:44 +00:00
feat: lambda without max-width
This commit is contained in:
parent
cb0863f4c0
commit
9d95a93051
1 changed files with 22 additions and 12 deletions
|
@ -4,9 +4,11 @@ pub fn rule(
|
||||||
) -> std::collections::LinkedList<crate::builder::Step> {
|
) -> std::collections::LinkedList<crate::builder::Step> {
|
||||||
let mut steps = std::collections::LinkedList::new();
|
let mut steps = std::collections::LinkedList::new();
|
||||||
|
|
||||||
let mut children = crate::children::Children::new(build_ctx, node);
|
let mut children = crate::children::Children::new_with_configuration(
|
||||||
|
build_ctx, node, true,
|
||||||
|
);
|
||||||
|
|
||||||
let layout = if children.has_comments() {
|
let layout = if children.has_comments() || children.has_newlines() {
|
||||||
&crate::config::Layout::Tall
|
&crate::config::Layout::Tall
|
||||||
} else {
|
} else {
|
||||||
build_ctx.config.layout()
|
build_ctx.config.layout()
|
||||||
|
@ -25,7 +27,8 @@ pub fn rule(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let rnix::SyntaxKind::TOKEN_COMMENT =
|
if let rnix::SyntaxKind::TOKEN_COMMENT
|
||||||
|
| rnix::SyntaxKind::TOKEN_WHITESPACE =
|
||||||
children.peek_next().unwrap().element.kind()
|
children.peek_next().unwrap().element.kind()
|
||||||
{
|
{
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
|
@ -33,10 +36,13 @@ pub fn rule(
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
children.drain_comments(|text| {
|
children.drain_comments_and_newlines(|element| match element {
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
crate::children::DrainCommentOrNewline::Comment(text) => {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
|
}
|
||||||
|
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
// :
|
// :
|
||||||
|
@ -51,10 +57,13 @@ pub fn rule(
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
children.drain_comments(|text| {
|
children.drain_comments_and_newlines(|element| match element {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
crate::children::DrainCommentOrNewline::Comment(text) => {
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
|
}
|
||||||
|
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
// c
|
// c
|
||||||
|
@ -65,7 +74,8 @@ pub fn rule(
|
||||||
if is_pattern_type {
|
if is_pattern_type {
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
steps.push_back(crate::builder::Step::Pad);
|
steps.push_back(crate::builder::Step::Pad);
|
||||||
} else if let rnix::SyntaxKind::TOKEN_COMMENT =
|
} else if let rnix::SyntaxKind::TOKEN_COMMENT
|
||||||
|
| rnix::SyntaxKind::TOKEN_WHITESPACE =
|
||||||
child_prev.element.kind()
|
child_prev.element.kind()
|
||||||
{
|
{
|
||||||
steps.push_back(crate::builder::Step::NewLine);
|
steps.push_back(crate::builder::Step::NewLine);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue