diff --git a/CHANGELOG.md b/CHANGELOG.md index ebee1eebcf..974166e6d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [Unreleased] + +### Fixed +* List of functions misaligned and breaks (Elmish). [#2158](https://github.com/fsprojects/fantomas/issues/2158) +* Idempotency problem when Elmish Html. [#2195](https://github.com/fsprojects/fantomas/issues/2195) +* Splitting list results in code that doesn't compile. [#2201](https://github.com/fsprojects/fantomas/issues/2201) +* Idempotency problem when using a list with interpolated strings. [#2242](https://github.com/fsprojects/fantomas/issues/2242) +* Idempotency problem when using set and spread syntax. [#2392](https://github.com/fsprojects/fantomas/issues/2392) + ## [5.0.0-beta-007] - 2022-08-19 ### Fixed diff --git a/src/Fantomas.Core.Tests/ListTests.fs b/src/Fantomas.Core.Tests/ListTests.fs index 757ff63690..75cca94dbe 100644 --- a/src/Fantomas.Core.Tests/ListTests.fs +++ b/src/Fantomas.Core.Tests/ListTests.fs @@ -2319,3 +2319,22 @@ let x: double[][] = [ [ 1.0, 2.0, 3.0 ] ] let foo (x: double[]) (y: object[][]) : string[,] = x :> int[] let foo<'T> (x: 'T[]) = x """ + +[] +let ``maintain indentation on function list, 2158`` () = + formatSourceString + false + """ +let fns = + Functions[Checked false + OnChange(fun _ -> s |> updateSettings)] +""" + config + |> prepend newline + |> should + equal + """ +let fns = + Functions[Checked false + OnChange(fun _ -> s |> updateSettings)] +""" diff --git a/src/Fantomas.Core/CodePrinter.fs b/src/Fantomas.Core/CodePrinter.fs index 2772abba74..359e9c1ec0 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -1401,9 +1401,11 @@ and genExpr astContext synExpr ctx = ) | IndexWithoutDotExpr (identifierExpr, indexExpr) -> + let genIndexExpr = genExpr astContext indexExpr + genExpr astContext identifierExpr +> sepOpenLFixed - +> genExpr astContext indexExpr + +> expressionFitsOnRestOfLine genIndexExpr (atCurrentColumnIndent genIndexExpr) +> sepCloseLFixed // Result.Ok 42