mirror of
https://github.com/RGBCube/alejandra
synced 2025-08-01 04:57:44 +00:00
Merge pull request #137 from kamadorueda/kamadorueda
feat: inline end at
This commit is contained in:
commit
dbb776942d
3 changed files with 19 additions and 5 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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 => {
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
self,
|
self,
|
||||||
gomod2nix,
|
gomod2nix,
|
||||||
mach-nix,
|
mach-nix,
|
||||||
}
|
} @ inp:
|
||||||
@ inp:
|
|
||||||
_)
|
_)
|
||||||
({}: _)
|
({}: _)
|
||||||
({ a }: _)
|
({ a }: _)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue