From ffecc484b7145c282ef20f16a47cffd0bba4d3c1 Mon Sep 17 00:00:00 2001 From: jindraivanek Date: Wed, 5 Sep 2018 18:12:13 +0200 Subject: [PATCH 1/2] test --- src/Fantomas.Tests/OperatorTests.fs | 7 +++++++ 1 file changed, 7 insertions(+) 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 From 28cfa5e3afd4b096ddde6e701fa2ed2d3f814c7a Mon Sep 17 00:00:00 2001 From: jindraivanek Date: Wed, 5 Sep 2018 18:13:05 +0200 Subject: [PATCH 2/2] Move check for NoBreakInfixOps on top --- src/Fantomas/CodePrinter.fs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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