mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 04:57:44 +00:00
Merge pull request #136 from kamadorueda/kamadorueda
feat: inline beggining at
This commit is contained in:
commit
4a7a938e8d
3 changed files with 23 additions and 7 deletions
|
@ -35,8 +35,10 @@ pub fn rule(
|
||||||
};
|
};
|
||||||
|
|
||||||
// x @
|
// x @
|
||||||
|
let mut at = false;
|
||||||
let child = children.peek_next().unwrap();
|
let child = children.peek_next().unwrap();
|
||||||
if let rnix::SyntaxKind::NODE_PAT_BIND = child.element.kind() {
|
if let rnix::SyntaxKind::NODE_PAT_BIND = child.element.kind() {
|
||||||
|
at = true;
|
||||||
match layout {
|
match layout {
|
||||||
crate::config::Layout::Tall => {
|
crate::config::Layout::Tall => {
|
||||||
steps.push_back(crate::builder::Step::FormatWider(
|
steps.push_back(crate::builder::Step::FormatWider(
|
||||||
|
@ -47,25 +49,28 @@ pub fn rule(
|
||||||
steps.push_back(crate::builder::Step::Format(child.element));
|
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();
|
children.move_next();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
|
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::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));
|
||||||
|
comment = true;
|
||||||
}
|
}
|
||||||
crate::children::DrainCommentOrNewline::Newline(_) => {}
|
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();
|
let child = children.get_next().unwrap();
|
||||||
steps.push_back(crate::builder::Step::Format(child.element));
|
steps.push_back(crate::builder::Step::Format(child.element));
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
[
|
[
|
||||||
|
(a@{
|
||||||
|
self,
|
||||||
|
gomod2nix,
|
||||||
|
mach-nix,
|
||||||
|
}: _)
|
||||||
({
|
({
|
||||||
self,
|
self,
|
||||||
gomod2nix,
|
gomod2nix,
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
[
|
[
|
||||||
|
(a @ {
|
||||||
|
self,
|
||||||
|
gomod2nix,
|
||||||
|
mach-nix,
|
||||||
|
}:
|
||||||
|
_)
|
||||||
({
|
({
|
||||||
self,
|
self,
|
||||||
gomod2nix,
|
gomod2nix,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue