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

feat: inline beggining at

This commit is contained in:
Kevin Amado 2022-02-18 12:02:32 -05:00
parent 38c93ab2b1
commit 8d10da6738
No known key found for this signature in database
GPG key ID: FFF341057F503148
3 changed files with 23 additions and 7 deletions

View file

@ -35,8 +35,10 @@ pub fn rule(
};
// x @
let mut at = false;
let child = children.peek_next().unwrap();
if let rnix::SyntaxKind::NODE_PAT_BIND = child.element.kind() {
at = true;
match layout {
crate::config::Layout::Tall => {
steps.push_back(crate::builder::Step::FormatWider(
@ -47,25 +49,28 @@ pub fn rule(
steps.push_back(crate::builder::Step::Format(child.element));
}
}
if !has_comments && items_count <= 1 {
steps.push_back(crate::builder::Step::Whitespace);
} else {
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
}
children.move_next();
}
// /**/
let mut comment = false;
children.drain_comments_and_newlines(|element| match element {
crate::children::DrainCommentOrNewline::Comment(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));
comment = true;
}
crate::children::DrainCommentOrNewline::Newline(_) => {}
});
if comment {
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
} else if at {
steps.push_back(crate::builder::Step::Whitespace);
}
// {
let child = children.get_next().unwrap();
steps.push_back(crate::builder::Step::Format(child.element));

View file

@ -1,4 +1,9 @@
[
(a@{
self,
gomod2nix,
mach-nix,
}: _)
({
self,
gomod2nix,

View file

@ -1,4 +1,10 @@
[
(a @ {
self,
gomod2nix,
mach-nix,
}:
_)
({
self,
gomod2nix,