diff --git a/src/Fantomas.Tests/KeepIndentInBranchTests.fs b/src/Fantomas.Tests/KeepIndentInBranchTests.fs index f3578179c5..84e683d305 100644 --- a/src/Fantomas.Tests/KeepIndentInBranchTests.fs +++ b/src/Fantomas.Tests/KeepIndentInBranchTests.fs @@ -1830,3 +1830,93 @@ let private parseModel (modelSrc: string) : Result = else Error validationErrors """ + +[] +let ``tuple is consider as short branch, 1800`` () = + formatSourceString + false + """ + let nextModel, objectsRemoved = + List.fold + (fun acc item -> + match entityInCurrentModel with + | None -> + // look it's a tuple + nextModel, objectsRemoved + | Some subjectToRemove -> + let a = 5 + let b = 6 + someFunctionApp a b |> ignore + acc) + state + [] +""" + { config with + MultiLineLambdaClosingNewline = true + KeepIndentInBranch = true } + |> prepend newline + |> should + equal + """ +let nextModel, objectsRemoved = + List.fold + (fun acc item -> + match entityInCurrentModel with + | None -> + // look it's a tuple + nextModel, objectsRemoved + | Some subjectToRemove -> + + let a = 5 + let b = 6 + someFunctionApp a b |> ignore + acc + ) + state + [] +""" + +[] +let ``parenthesis tuple is consider as short branch`` () = + formatSourceString + false + """ + let nextModel, objectsRemoved = + List.fold + (fun acc item -> + match entityInCurrentModel with + | None -> + // look it's a tuple but wrapped in parenthesis + (nextModel, objectsRemoved) + | Some subjectToRemove -> + let a = 5 + let b = 6 + someFunctionApp a b |> ignore + acc) + state + [] +""" + { config with + MultiLineLambdaClosingNewline = true + KeepIndentInBranch = true } + |> prepend newline + |> should + equal + """ +let nextModel, objectsRemoved = + List.fold + (fun acc item -> + match entityInCurrentModel with + | None -> + // look it's a tuple but wrapped in parenthesis + (nextModel, objectsRemoved) + | Some subjectToRemove -> + + let a = 5 + let b = 6 + someFunctionApp a b |> ignore + acc + ) + state + [] +""" diff --git a/src/Fantomas/SourceParser.fs b/src/Fantomas/SourceParser.fs index 364aa3c286..45a114a3d4 100644 --- a/src/Fantomas/SourceParser.fs +++ b/src/Fantomas/SourceParser.fs @@ -1730,7 +1730,9 @@ let private shouldNotIndentBranch e es = match e with | SimpleExpr _ | Sequential (_, _, true) - | App _ -> true + | App _ + | Tuple _ + | Paren (_, Tuple _, _, _) -> true | _ -> false let isLongElseBranch e =