1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-08-01 04:57:44 +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); steps.push_back(crate::builder::Step::Pad);
} }
crate::config::Layout::Wide => { 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)); steps.push_back(crate::builder::Step::Format(child.element));

View file

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

View file

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

View file

@ -1,5 +1,5 @@
[ [
{ } {}
{ {
/* /*
a a
@ -101,7 +101,7 @@
a = { a = {
a = rec { a = rec {
a = { 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}"; url = "example/${version}";
}; };
meta = with lib; { meta = with lib; {
maintainers = with maintainers; [ someone ]; maintainers = with maintainers; [someone];
description = "something"; description = "something";
}; };
} }

View file

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

View file

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

View file

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

View file

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

View file

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