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

Merge pull request #113 from kamadorueda/kamadorueda

feat: no space in empty containers
This commit is contained in:
Kevin Amado 2022-02-16 20:14:12 -05:00 committed by GitHub
commit 1de952b26a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 30 additions and 27 deletions

View file

@ -127,7 +127,9 @@ pub fn rule(
steps.push_back(crate::builder::Step::Pad);
}
crate::config::Layout::Wide => {
steps.push_back(crate::builder::Step::Whitespace);
if items_count > 0 {
steps.push_back(crate::builder::Step::Whitespace);
}
}
}
steps.push_back(crate::builder::Step::Format(child.element));

View file

@ -69,7 +69,9 @@ pub fn rule(
));
}
crate::config::Layout::Wide => {
steps.push_back(crate::builder::Step::Whitespace);
if item_index > 1 {
steps.push_back(crate::builder::Step::Whitespace);
}
steps
.push_back(crate::builder::Step::Format(child.element));
}
@ -87,9 +89,7 @@ pub fn rule(
steps.push_back(crate::builder::Step::NewLine);
steps.push_back(crate::builder::Step::Pad);
}
crate::config::Layout::Wide => {
steps.push_back(crate::builder::Step::Whitespace);
}
crate::config::Layout::Wide => {}
}
steps.push_back(crate::builder::Step::Format(child.element));

View file

@ -153,8 +153,9 @@ pub fn rule(
// }
let child = children.get_next().unwrap();
steps.push_back(crate::builder::Step::Dedent);
if !has_comments_between_curly_b && items_count <= 1 {
if !has_comments_between_curly_b && items_count == 1 {
steps.push_back(crate::builder::Step::Whitespace);
} else if !has_comments_between_curly_b && items_count == 0 {
} else {
if let rnix::SyntaxKind::NODE_PAT_ENTRY = last_kind {
steps.push_back(crate::builder::Step::Token(

View file

@ -1,5 +1,5 @@
[
{ }
{}
{
/*
a
@ -101,7 +101,7 @@
a = {
a = rec {
a = {
a = rec { a = { a = rec { a = { a = rec { a = { }; }; }; }; }; };
a = rec { a = { a = rec { a = { a = rec { a = {}; }; }; }; }; };
};
};
};

View file

@ -19,7 +19,7 @@
url = "example/${version}";
};
meta = with lib; {
maintainers = with maintainers; [ someone ];
maintainers = with maintainers; [someone];
description = "something";
};
}

View file

@ -94,13 +94,13 @@ rec
b = 1;
c = 2;
};
n = pkgs: { };
n = pkgs: {};
o =
{
pkgs,
...
}:
{ };
{};
a
/*
@ -117,6 +117,6 @@ rec
;
p =
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa { }
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa {}
a;
}

View file

@ -7,7 +7,7 @@
d
)
(
{ }:
{}:
b:
/*
c
@ -16,7 +16,7 @@
)
(
a:
{ }:
{}:
/*
c
*/
@ -57,14 +57,14 @@
)
(
{
pkgs ? import ./.. { },
pkgs ? import ./.. {},
locationsXml,
}:
null
)
(
a: b: c:
{ }:
{}:
a: b: c:
a
)

View file

@ -1,11 +1,11 @@
[
[ 1 ]
[1]
[
1
]
[ b d ]
[b d]
[
b
d

View file

@ -1,19 +1,19 @@
[
({ } @ a: _)
({} @ a: _)
(
{ } @
{} @
/**/
a:
_
)
(
{ }
{}
/**/
@ a:
_
)
(
{ }
{}
/**/
@
/**/
@ -21,17 +21,17 @@
_
)
(a @ { }: _)
(a @ {}: _)
(
a @
/**/
{ }:
{}:
_
)
(
a
/**/
@ { }:
@ {}:
_
)
(
@ -39,7 +39,7 @@
/**/
@
/**/
{ }:
{}:
_
)
]

View file

@ -8,7 +8,7 @@
@ inp:
_
)
({ }: _)
({}: _)
({ a }: _)
(
{