mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 04:57:44 +00:00
feat: remove unnecesary newlines
This commit is contained in:
parent
72ab2888b3
commit
d8482d7619
1 changed files with 3 additions and 4 deletions
|
@ -25,19 +25,18 @@ pub fn rule(
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
|
let mut comment = false;
|
||||||
children.drain_comments_and_newlines(|element| match element {
|
children.drain_comments_and_newlines(|element| match element {
|
||||||
crate::children::DrainCommentOrNewline::Comment(text) => {
|
crate::children::DrainCommentOrNewline::Comment(text) => {
|
||||||
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);
|
||||||
steps.push_back(crate::builder::Step::Comment(text));
|
steps.push_back(crate::builder::Step::Comment(text));
|
||||||
|
comment = true;
|
||||||
}
|
}
|
||||||
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
||||||
});
|
});
|
||||||
|
|
||||||
if let rnix::SyntaxKind::TOKEN_COMMENT
|
if comment {
|
||||||
| rnix::SyntaxKind::TOKEN_WHITESPACE =
|
|
||||||
children.peek_prev().unwrap().element.kind()
|
|
||||||
{
|
|
||||||
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 {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue