Fix formatter adding extra unnecessary newlines after literal lists clause values or assignments.
This commit is contained in:
parent
d6c728c0f6
commit
12c0d0bc04
|
@ -9,6 +9,7 @@
|
|||
### Changed
|
||||
|
||||
- **aiken-project**: Fix documentation link-tree generation messing up with modules when re-inserting the same module. @KtorZ
|
||||
- **aiken-lang**: Fix formatter adding extra unnecessary newlines after literal lists clause values or assignments. @KtorZ
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -28,6 +29,7 @@
|
|||
- **aiken-lang**: Adjust reification of `String` to be shown as plain UTF-8 text strings (instead of hex-encoded byte array). @KtorZ
|
||||
- **aiken-lang**: Fix formatting of long if-condition over multiline. @KtorZ & @Microproofs
|
||||
- **aiken-lang**: Fix formatting of standalone logical binary chains (`and` & `or`) in functions. @KtorZ
|
||||
- **uplc**: Fix script context generation failure on missing datum when evaluating transactions. @solidsnakedev
|
||||
|
||||
### Removed
|
||||
|
||||
|
|
|
@ -1889,9 +1889,7 @@ impl<'comments> Formatter<'comments> {
|
|||
.force_break(),
|
||||
),
|
||||
|
||||
UntypedExpr::Fn { .. } | UntypedExpr::List { .. } => {
|
||||
line().append(self.expr(expr, false)).nest(INDENT).group()
|
||||
}
|
||||
UntypedExpr::Fn { .. } => line().append(self.expr(expr, false)).nest(INDENT).group(),
|
||||
|
||||
UntypedExpr::When { .. } => line().append(self.expr(expr, false)).nest(INDENT).group(),
|
||||
|
||||
|
@ -1976,6 +1974,7 @@ impl<'comments> Formatter<'comments> {
|
|||
} else {
|
||||
|| break_(",", ", ")
|
||||
};
|
||||
|
||||
let elements_document =
|
||||
join(elements.iter().map(|e| self.pattern(e)), break_style());
|
||||
let tail = tail.as_ref().map(|e| {
|
||||
|
|
|
@ -298,6 +298,7 @@ fn format_nested_when_if() {
|
|||
when xs is {
|
||||
[] ->
|
||||
[]
|
||||
[x] -> [1, 2, 3]
|
||||
[_x, ..rest] ->
|
||||
drop(rest, n - 1)
|
||||
}
|
||||
|
|
|
@ -3,8 +3,7 @@ source: crates/aiken-lang/src/tests/format.rs
|
|||
description: "Code:\n\ntest foo() {\n let left =\n [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n let right =\n [\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n 0, 0, 0, 0,\n ]\n left == right\n}\n"
|
||||
---
|
||||
test foo() {
|
||||
let left =
|
||||
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
let left = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
let right =
|
||||
[
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
---
|
||||
source: crates/aiken-lang/src/tests/format.rs
|
||||
description: "Code:\n\npub fn drop(xs: List<a>, n: Int) -> List<a> {\n if n <= 0 {\n xs\n } else {\n when xs is {\n [] ->\n []\n [_x, ..rest] ->\n drop(rest, n - 1)\n }\n }\n}\n"
|
||||
description: "Code:\n\npub fn drop(xs: List<a>, n: Int) -> List<a> {\n if n <= 0 {\n xs\n } else {\n when xs is {\n [] ->\n []\n [x] -> [1, 2, 3]\n [_x, ..rest] ->\n drop(rest, n - 1)\n }\n }\n}\n"
|
||||
---
|
||||
pub fn drop(xs: List<a>, n: Int) -> List<a> {
|
||||
if n <= 0 {
|
||||
xs
|
||||
} else {
|
||||
when xs is {
|
||||
[] ->
|
||||
[]
|
||||
[] -> []
|
||||
[x] -> [1, 2, 3]
|
||||
[_x, ..rest] -> drop(rest, n - 1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue