diff --git a/src/Fantomas.Tests/ComputationExpressionTests.fs b/src/Fantomas.Tests/ComputationExpressionTests.fs index 4873870aed..9eb4d3030c 100644 --- a/src/Fantomas.Tests/ComputationExpressionTests.fs +++ b/src/Fantomas.Tests/ComputationExpressionTests.fs @@ -1315,4 +1315,61 @@ let a = let! bar = async { return foo a } return bar } +""" + +[] +let ``new line between let and let bang, 879`` () = + formatSourceString false """let rec loop () = + async { + let! msg = inbox.Receive() + + match msg with + | Handle (eventSource,command,reply) -> + let! stream = eventSource |> eventStore.GetStream + + let newEvents = + stream |> Result.map (asEvents >> behaviour command >> enveloped eventSource) + + let! result = + newEvents + |> function + | Ok events -> eventStore.Append events + | Error err -> async { return Error err } + + do reply.Reply result + + return! loop () + } +""" ({ config with + SpaceBeforeUppercaseInvocation = true + IndentSpaceNum = 2 + SpaceAroundDelimiter = false + MultilineBlockBracketsOnSameColumn = true }) + |> prepend newline + |> should equal """ +let rec loop () = + async { + let! msg = inbox.Receive () + + match msg with + | Handle (eventSource, command, reply) -> + let! stream = eventSource |> eventStore.GetStream + + let newEvents = + stream + |> Result.map + (asEvents + >> behaviour command + >> enveloped eventSource) + + let! result = + newEvents + |> function + | Ok events -> eventStore.Append events + | Error err -> async { return Error err} + + do reply.Reply result + + return! loop () + } """ \ No newline at end of file diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index fcd31f808e..2fd0ab220c 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -968,8 +968,9 @@ and genExpr astContext synExpr = sprintf "%s%s" (if isUse then "use " else "let ") (if isRecursive then "rec " else "") genLetBinding astContext prefix binding - | LetOrUseBangStatement(isUse, pat, expr, _) -> - ifElse isUse (!- "use! ") (!- "let! ") + | LetOrUseBangStatement(isUse, pat, expr, r) -> + enterNode r // print Trivia before entire LetBang expression + +> ifElse isUse (!- "use! ") (!- "let! ") +> genPat astContext pat -- " = " +> autoIndentAndNlnIfExpressionExceedsPageWidth (genExpr astContext expr) | AndBangStatement(pat, expr) ->