diff --git a/src/Fantomas.Tests/OperatorTests.fs b/src/Fantomas.Tests/OperatorTests.fs index 08a9320014..a1c00dbee3 100644 --- a/src/Fantomas.Tests/OperatorTests.fs +++ b/src/Fantomas.Tests/OperatorTests.fs @@ -175,4 +175,11 @@ let ``should pipeline monadic bind``() = >>= strAddLong "A long argument that is ignored" "2" >>= strAddLong "A long argument that is ignored" "2" >>= strAddLong "A long argument that is ignored" "2" +""" + +[] +let ``should not add newline before = operator after |>``() = + formatSourceString false """1 |> max 0 = 1""" config + |> should equal """1 +|> max 0 = 1 """ \ No newline at end of file diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index 69ae007de5..739d392f38 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -685,15 +685,15 @@ and genLetOrUseList astContext = function /// When 'hasNewLine' is set, the operator is forced to be in a new line and genInfixApps astContext hasNewLine synExprs = match synExprs with + | (s, e)::es when (NoBreakInfixOps.Contains s) -> + (sepSpace -- s +> sepSpace +> genExpr astContext e) + +> genInfixApps astContext (hasNewLine || checkNewLine e es) es | (s, e)::es when(hasNewLine) -> (sepNln -- s +> sepSpace +> genExpr astContext e) +> genInfixApps astContext (hasNewLine || checkNewLine e es) es | (s, e)::es when(NoSpaceInfixOps.Contains s) -> (!- s +> autoNln (genExpr astContext e)) +> genInfixApps astContext (hasNewLine || checkNewLine e es) es - | (s, e)::es when (NoBreakInfixOps.Contains s) -> - (sepSpace -- s +> sepSpace +> genExpr astContext e) - +> genInfixApps astContext (hasNewLine || checkNewLine e es) es | (s, e)::es -> (sepSpace +> autoNln (!- s +> sepSpace +> genExpr astContext e)) +> genInfixApps astContext (hasNewLine || checkNewLine e es) es