mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 12:37:45 +00:00
feat: remove top level disctinction in let-in
This commit is contained in:
parent
f8e7b233bd
commit
60e9e2cba7
3 changed files with 32 additions and 17 deletions
36
CHANGELOG.md
36
CHANGELOG.md
|
@ -7,28 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Types of changes
|
||||||
|
- Added for new features.
|
||||||
|
- Changed for changes in existing functionality.
|
||||||
|
- Deprecated for soon-to-be removed features.
|
||||||
|
- Removed for now removed features.
|
||||||
|
- Fixed for any bug fixes.
|
||||||
|
- Security in case of vulnerabilities.
|
||||||
|
-->
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Let-in expressions are now indented in the top-level of a file.
|
||||||
|
|
||||||
## [0.2.0] - 2022-02-17
|
## [0.2.0] - 2022-02-17
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
- A `--version` flag to the CLI.
|
||||||
- Pre-built binaries for x86_64-linux and aarch64-linux.
|
- Pre-built binaries for x86_64-linux and aarch64-linux.
|
||||||
|
- Support for inline comments on lists, attr-sets, and let-in expressions.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
- Made the logic of the `or-default` (`a or b`) node
|
- Made the logic of the `or-default` (`a or b`) node
|
||||||
to be equal to the binary operator (`a $operator b`).
|
to be equal to the binary operator (`a $operator b`).
|
||||||
This increases consistency across the same family of elements.
|
This increases consistency across the same family of elements.
|
||||||
- Remove users freedom to insert newlines
|
- Reduce 1 indentation level in `let-in` expressions,
|
||||||
|
when the target expression is a parenthesis, attr-set, list, or string.
|
||||||
|
- String interpolations in multi-line strings
|
||||||
|
now have a nice-looking indentation.
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- Users freedom to insert newlines
|
||||||
before the `?` in pattern bindings (`a ? b`).
|
before the `?` in pattern bindings (`a ? b`).
|
||||||
|
|
||||||
Inserting a newline after the `?` is still possible.
|
Inserting a newline after the `?` is still possible.
|
||||||
|
|
||||||
This increases consistency on where to break a long pattern binding.
|
This increases consistency on where to break a long pattern binding.
|
||||||
|
|
||||||
- Remove space on empty containers (`[]`, `{}`).
|
- Space on empty containers (`[]`, `{}`).
|
||||||
- Add a `--version` flag to the CLI.
|
|
||||||
- Reduce 1 indentation level in `let-in` expressions,
|
|
||||||
when the target expression is a parenthesis, attr-set, list, or string.
|
|
||||||
- Support inline comments on lists, attr-sets, and let-in expressions.
|
|
||||||
- String interpolations in multi-line strings
|
|
||||||
now have a nice-looking indentation.
|
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,6 @@ pub fn rule(
|
||||||
|
|
||||||
// in
|
// in
|
||||||
let child_in = children.get_next().unwrap();
|
let child_in = children.get_next().unwrap();
|
||||||
let top_level = build_ctx.pos_new.column <= 1;
|
|
||||||
|
|
||||||
// /**/
|
// /**/
|
||||||
let mut child_comments = std::collections::LinkedList::new();
|
let mut child_comments = std::collections::LinkedList::new();
|
||||||
|
@ -132,9 +131,7 @@ pub fn rule(
|
||||||
{
|
{
|
||||||
steps.push_back(crate::builder::Step::Whitespace);
|
steps.push_back(crate::builder::Step::Whitespace);
|
||||||
} else {
|
} else {
|
||||||
if !top_level {
|
steps.push_back(crate::builder::Step::Indent);
|
||||||
steps.push_back(crate::builder::Step::Indent);
|
|
||||||
}
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -155,9 +152,7 @@ pub fn rule(
|
||||||
steps.push_back(crate::builder::Step::FormatWider(
|
steps.push_back(crate::builder::Step::FormatWider(
|
||||||
child_expr.element,
|
child_expr.element,
|
||||||
));
|
));
|
||||||
if !top_level {
|
steps.push_back(crate::builder::Step::Dedent);
|
||||||
steps.push_back(crate::builder::Step::Dedent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
crate::config::Layout::Wide => {
|
crate::config::Layout::Wide => {
|
||||||
steps.push_back(crate::builder::Step::Whitespace);
|
steps.push_back(crate::builder::Step::Whitespace);
|
||||||
|
|
|
@ -88,5 +88,5 @@ let
|
||||||
2
|
2
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
/**/
|
/**/
|
||||||
a
|
a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue