diff --git a/CHANGELOG.md b/CHANGELOG.md index f8a5d3fa5..b47d80445 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ # Changelog -## [Unreleased] +## 6.3.8 - 2024-06-06 ### Fixed -* Fix loss of tuple type annotation without parens. [#2942](https://github.com/fsprojects/fantomas/issues/2942) +* Fix precedence change of `||>` due to inserted newline. [#2866](https://github.com/fsprojects/fantomas/issues/2866) ## 6.3.7 - 2024-06-01 diff --git a/src/Fantomas.Core.Tests/PatternMatchingTests.fs b/src/Fantomas.Core.Tests/PatternMatchingTests.fs index 74db05a60..6b4bb8638 100644 --- a/src/Fantomas.Core.Tests/PatternMatchingTests.fs +++ b/src/Fantomas.Core.Tests/PatternMatchingTests.fs @@ -2286,3 +2286,26 @@ match synExpr with ) -> Some ident.idRange | _ -> defaultTraverse synExpr """ + +[] +let ``insertion of a newline changes precedence of the ||> operator, 2866`` () = + formatSourceString + """ +let value = + match "string" with + | "value" -> "1", "2" + | _ -> "111111111111111111111111111111111111111111111111111111111111111111111", "22222222222222222222222222222222222" + ||> createTuple +""" + config + |> prepend newline + |> should + equal + """ +let value = + (match "string" with + | "value" -> "1", "2" + | _ -> + "111111111111111111111111111111111111111111111111111111111111111111111", "22222222222222222222222222222222222") + ||> createTuple +""" diff --git a/src/Fantomas.Core/CodePrinter.fs b/src/Fantomas.Core/CodePrinter.fs index de5cba95e..5a13896a6 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -2163,7 +2163,7 @@ let genMultilineInfixExpr (node: ExprInfixAppNode) = match node.LeftHandSide with | IsIfThenElse _ when (ctx.Config.IndentSize - 1 <= node.Operator.Text.Length) -> autoParenthesisIfExpressionExceedsPageWidth (genExpr node.LeftHandSide) ctx - | Expr.Match _ when (ctx.Config.IndentSize <= node.Operator.Text.Length) -> + | Expr.Match _ when (ctx.Config.IndentSize - 1 <= node.Operator.Text.Length) -> let ctxAfterMatch = genExpr node.LeftHandSide ctx let lastClauseIsSingleLine =