1
Fork 0
mirror of https://github.com/RGBCube/alejandra synced 2025-08-01 13:07:47 +00:00

feat: inline end at

This commit is contained in:
Kevin Amado 2022-02-18 12:14:03 -05:00
parent 4a7a938e8d
commit fa8d747441
No known key found for this signature in database
GPG key ID: FFF341057F503148
3 changed files with 19 additions and 5 deletions

View file

@ -20,6 +20,19 @@ Types of changes
### Changed ### Changed
- Let-in expressions are now indented in the top-level of a file. - Let-in expressions are now indented in the top-level of a file.
- Patterns avoid a new line after `@`:
```nix
- args @
- {
+ args @ {
```
```nix
- }
- @ inp:
+ } @ inp:
```
## [0.2.0] - 2022-02-17 ## [0.2.0] - 2022-02-17

View file

@ -174,11 +174,13 @@ pub fn rule(
steps.push_back(crate::builder::Step::Format(child.element)); steps.push_back(crate::builder::Step::Format(child.element));
// /**/ // /**/
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::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)); steps.push_back(crate::builder::Step::Comment(text));
comment = true;
} }
crate::children::DrainCommentOrNewline::Newline(_) => {} crate::children::DrainCommentOrNewline::Newline(_) => {}
}); });
@ -186,11 +188,11 @@ pub fn rule(
// @ x // @ x
if let Some(child) = children.peek_next() { if let Some(child) = children.peek_next() {
if let rnix::SyntaxKind::NODE_PAT_BIND = child.element.kind() { if let rnix::SyntaxKind::NODE_PAT_BIND = child.element.kind() {
if !has_comments && items_count <= 1 { if comment {
steps.push_back(crate::builder::Step::Whitespace);
} else {
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);
} else {
steps.push_back(crate::builder::Step::Whitespace);
} }
match layout { match layout {
crate::config::Layout::Tall => { crate::config::Layout::Tall => {

View file

@ -9,8 +9,7 @@
self, self,
gomod2nix, gomod2nix,
mach-nix, mach-nix,
} } @ inp:
@ inp:
_) _)
({}: _) ({}: _)
({ a }: _) ({ a }: _)