mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 04:57:44 +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 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() {
|
let layout = if children.has_comments() {
|
||||||
&crate::config::Layout::Tall
|
&crate::config::Layout::Tall
|
||||||
|
} else if items_count > 1 {
|
||||||
|
&crate::config::Layout::Tall
|
||||||
} else {
|
} else {
|
||||||
build_ctx.config.layout()
|
build_ctx.config.layout()
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
let
|
let
|
||||||
|
/**/
|
||||||
|
a = let b=2; c=3; in d;
|
||||||
/**/
|
/**/
|
||||||
a = let c=1; in f;
|
a = let c=1; in f;
|
||||||
/**/
|
/**/
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
let
|
let
|
||||||
/**/
|
/**/
|
||||||
|
a =
|
||||||
|
let
|
||||||
|
b = 2;
|
||||||
|
c = 3;
|
||||||
|
in
|
||||||
|
d;
|
||||||
|
/**/
|
||||||
a = let c = 1; in f;
|
a = let c = 1; in f;
|
||||||
/**/
|
/**/
|
||||||
a =
|
a =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue