mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 12:37:45 +00:00
feat: expand multi-item let-in
This commit is contained in:
parent
b61724a5a4
commit
41ff5e9b8b
3 changed files with 21 additions and 0 deletions
|
@ -6,8 +6,20 @@ pub fn rule(
|
|||
|
||||
let mut children = crate::children::Children::new(build_ctx, node);
|
||||
|
||||
let items_count = node
|
||||
.children()
|
||||
.filter(|element| match element.kind() {
|
||||
rnix::SyntaxKind::NODE_KEY_VALUE
|
||||
| rnix::SyntaxKind::NODE_INHERIT
|
||||
| rnix::SyntaxKind::NODE_INHERIT_FROM => true,
|
||||
_ => false,
|
||||
})
|
||||
.count();
|
||||
|
||||
let layout = if children.has_comments() {
|
||||
&crate::config::Layout::Tall
|
||||
} else if items_count > 1 {
|
||||
&crate::config::Layout::Tall
|
||||
} else {
|
||||
build_ctx.config.layout()
|
||||
};
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
let
|
||||
/**/
|
||||
a = let b=2; c=3; in d;
|
||||
/**/
|
||||
a = let c=1; in f;
|
||||
/**/
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
let
|
||||
/**/
|
||||
a =
|
||||
let
|
||||
b = 2;
|
||||
c = 3;
|
||||
in
|
||||
d;
|
||||
/**/
|
||||
a = let c = 1; in f;
|
||||
/**/
|
||||
a =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue