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:
parent
38c93ab2b1
commit
8d10da6738
3 changed files with 23 additions and 7 deletions
|
@ -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));
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
[
|
||||
(a@{
|
||||
self,
|
||||
gomod2nix,
|
||||
mach-nix,
|
||||
}: _)
|
||||
({
|
||||
self,
|
||||
gomod2nix,
|
||||
|
|
|
@ -1,4 +1,10 @@
|
|||
[
|
||||
(a @ {
|
||||
self,
|
||||
gomod2nix,
|
||||
mach-nix,
|
||||
}:
|
||||
_)
|
||||
({
|
||||
self,
|
||||
gomod2nix,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue