Skip to content

feat: remove top level disctinction in let-in #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [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

### Added

- A `--version` flag to the CLI.
- 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
to be equal to the binary operator (`a $operator b`).
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`).

Inserting a newline after the `?` is still possible.

This increases consistency on where to break a long pattern binding.

- Remove 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.
- Space on empty containers (`[]`, `{}`).

### Fixed

Expand Down
9 changes: 2 additions & 7 deletions src/rules/let_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ pub fn rule(

// in
let child_in = children.get_next().unwrap();
let top_level = build_ctx.pos_new.column <= 1;

// /**/
let mut child_comments = std::collections::LinkedList::new();
Expand Down Expand Up @@ -132,9 +131,7 @@ pub fn rule(
{
steps.push_back(crate::builder::Step::Whitespace);
} 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::Pad);
}
Expand All @@ -155,9 +152,7 @@ pub fn rule(
steps.push_back(crate::builder::Step::FormatWider(
child_expr.element,
));
if !top_level {
steps.push_back(crate::builder::Step::Dedent);
}
steps.push_back(crate::builder::Step::Dedent);
}
crate::config::Layout::Wide => {
steps.push_back(crate::builder::Step::Whitespace);
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/let_in/out
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ let
2
];
in
/**/
a
/**/
a