mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 12:37:45 +00:00
feat: apply without max-width
This commit is contained in:
parent
f179b2e855
commit
d2e2f6c20b
4 changed files with 51 additions and 25 deletions
|
@ -4,9 +4,11 @@ pub fn rule(
|
|||
) -> std::collections::LinkedList<crate::builder::Step> {
|
||||
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
|
||||
} else {
|
||||
build_ctx.config.layout()
|
||||
|
@ -24,10 +26,13 @@ pub fn rule(
|
|||
}
|
||||
|
||||
// /**/
|
||||
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));
|
||||
children.drain_comments_and_newlines(|element| match element {
|
||||
crate::children::DrainCommentOrNewline::Comment(text) => {
|
||||
steps.push_back(crate::builder::Step::NewLine);
|
||||
steps.push_back(crate::builder::Step::Pad);
|
||||
steps.push_back(crate::builder::Step::Comment(text));
|
||||
}
|
||||
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
||||
});
|
||||
|
||||
let child_prev = children.peek_prev().unwrap();
|
||||
|
@ -36,7 +41,9 @@ pub fn rule(
|
|||
let child = children.get_next().unwrap();
|
||||
match layout {
|
||||
crate::config::Layout::Tall => {
|
||||
if let rnix::SyntaxKind::TOKEN_COMMENT = child_prev.element.kind() {
|
||||
if let rnix::SyntaxKind::TOKEN_COMMENT
|
||||
| rnix::SyntaxKind::TOKEN_WHITESPACE = child_prev.element.kind()
|
||||
{
|
||||
steps.push_back(crate::builder::Step::NewLine);
|
||||
steps.push_back(crate::builder::Step::Pad);
|
||||
} else if let rnix::SyntaxKind::NODE_ATTR_SET
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
(a b) (a b) (
|
||||
(a b)
|
||||
(a b)
|
||||
(
|
||||
a
|
||||
/*
|
||||
b
|
||||
*/
|
||||
c
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
|
|
@ -116,5 +116,6 @@ rec
|
|||
;
|
||||
|
||||
p =
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { } a;
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { }
|
||||
a;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
(
|
||||
((c)) (
|
||||
((c))
|
||||
(
|
||||
(c)
|
||||
/*
|
||||
e
|
||||
*/
|
||||
) (
|
||||
)
|
||||
(
|
||||
(
|
||||
c
|
||||
/*
|
||||
d
|
||||
*/
|
||||
)
|
||||
) (
|
||||
)
|
||||
(
|
||||
(
|
||||
c
|
||||
/*
|
||||
|
@ -21,14 +24,16 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
) (
|
||||
)
|
||||
(
|
||||
(
|
||||
/*
|
||||
b
|
||||
*/
|
||||
c
|
||||
)
|
||||
) (
|
||||
)
|
||||
(
|
||||
(
|
||||
/*
|
||||
b
|
||||
|
@ -38,7 +43,8 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
) (
|
||||
)
|
||||
(
|
||||
(
|
||||
/*
|
||||
b
|
||||
|
@ -48,7 +54,8 @@
|
|||
d
|
||||
*/
|
||||
)
|
||||
) (
|
||||
)
|
||||
(
|
||||
(
|
||||
/*
|
||||
b
|
||||
|
@ -61,12 +68,14 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
(c)
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
@ -74,7 +83,8 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
@ -84,7 +94,8 @@
|
|||
d
|
||||
*/
|
||||
)
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
@ -97,7 +108,8 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
@ -107,7 +119,8 @@
|
|||
*/
|
||||
c
|
||||
)
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
@ -120,7 +133,8 @@
|
|||
/*
|
||||
e
|
||||
*/
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
@ -133,7 +147,8 @@
|
|||
d
|
||||
*/
|
||||
)
|
||||
) (
|
||||
)
|
||||
(
|
||||
/*
|
||||
a
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue