diff --git a/.paket/paket.exe b/.paket/paket.exe index 0a333fd7c0..8ef0a68ac1 100644 Binary files a/.paket/paket.exe and b/.paket/paket.exe differ diff --git a/src/Fantomas.Tests/PatternMatchingTests.fs b/src/Fantomas.Tests/PatternMatchingTests.fs index 4ae52adcf5..2197249fa2 100644 --- a/src/Fantomas.Tests/PatternMatchingTests.fs +++ b/src/Fantomas.Tests/PatternMatchingTests.fs @@ -414,7 +414,7 @@ let update msg model = """ [] -let ``updated record with function call should be on newline, even though short`` () = +let ``updated record with function call remains be on same line, because short enough`` () = formatSourceString false """ let x = { Value = 36 }.Times(9) @@ -426,6 +426,5 @@ match b with let x = { Value = 36 }.Times(9) match b with -| _ -> - { Value = 42 }.Times(8) +| _ -> { Value = 42 }.Times(8) """ \ No newline at end of file diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index fb111a6637..19fc90fd70 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -265,8 +265,9 @@ and breakNlnOrAddSpace astContext brk e = (indent +> autoNlnOrSpace (genExpr astContext e) +> unindent) /// Preserve a break even if the expression is a one-liner -and preserveBreakNln astContext e ctx = - breakNln astContext (checkPreserveBreakForExpr e ctx) e ctx +and preserveBreakNln astContext e ctx = + let brk = checkPreserveBreakForExpr e ctx || futureNlnCheck (genExpr astContext e) sepNone ctx + breakNln astContext brk e ctx and preserveBreakNlnOrAddSpace astContext e ctx = breakNlnOrAddSpace astContext (checkPreserveBreakForExpr e ctx) e ctx @@ -1099,15 +1100,8 @@ and genInterfaceImpl astContext (InterfaceImpl(t, bs, range)) = +> indent +> sepNln +> genMemberBindingList { astContext with InterfaceRange = Some range } bs +> unindent and genClause astContext hasBar (Clause(p, e, eo)) = - ifElse hasBar sepBar sepNone +> genPat astContext p - +> optPre (!- " when ") sepNone eo (genExpr astContext) +> sepArrow +> (fun ctx -> - let alreadyMultiline = checkPreserveBreakForExpr e ctx - match alreadyMultiline, e with - | false, SynExpr.App(_,_,SynExpr.DotGet(SynExpr.Record(_, copyInfo,recordFields,_), _, LongIdentWithDots(lid), range),_,_) -> - (breakNln astContext true e) ctx - | _ -> - (breakNln astContext alreadyMultiline e) ctx - ) + ifElse hasBar sepBar sepNone +> genPat astContext p + +> optPre (!- " when ") sepNone eo (genExpr astContext) +> sepArrow +> preserveBreakNln astContext e /// Each multiline member definition has a pre and post new line. and genMemberDefnList astContext (*(interfaceRange:Microsoft.FSharp.Compiler.Range.range)*) = function