1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-08-01 04:57:44 +00:00

Merge pull request #110 from kamadorueda/kamadorueda

feat: remove unnecesary newlines
This commit is contained in:
Kevin Amado 2022-02-16 18:57:04 -05:00 committed by GitHub
commit 63f3a44880
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 10 deletions

View file

@ -9,12 +9,9 @@ steps:
queue: private queue: private
artifacts: artifacts:
# Builds on: aarch64-darwin # Builds on: aarch64-darwin
# - aarch64-apple-darwin # - alejandra-aarch64-apple-darwin
# Builds on: aarch64-linux # Builds on: aarch64-linux, x86_64-linux
# - aarch64-unknown-linux-musl
# Builds on: x86_64-linux
- alejandra-aarch64-unknown-linux-musl - alejandra-aarch64-unknown-linux-musl
# Builds on: x86_64-darwin # Builds on: x86_64-darwin
@ -68,7 +65,7 @@ steps:
- git clone --branch=master --depth 1 --origin=upstream file:///data/nixpkgs - git clone --branch=master --depth 1 --origin=upstream file:///data/nixpkgs
- echo --- Formatting - before - echo --- Formatting - before
- nix run github:kamadorueda/alejandra -- nixpkgs 2>/dev/null - nix --tarball-ttl 1 run github:kamadorueda/alejandra -- nixpkgs 2>/dev/null
- git -C nixpkgs add . - git -C nixpkgs add .
- git -C nixpkgs commit -m formatting-before -q - git -C nixpkgs commit -m formatting-before -q
- git -C nixpkgs branch formatting-before - git -C nixpkgs branch formatting-before

View file

@ -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 {