From 4555065e68e011a0faeb9d2239144d9bf47aac50 Mon Sep 17 00:00:00 2001 From: nojaf Date: Wed, 23 Jun 2021 11:19:47 +0200 Subject: [PATCH] Consider all function applications as short branch. Fixes #1779. --- src/Fantomas.Tests/KeepIndentInBranchTests.fs | 60 +++++++++++++++++++ src/Fantomas/SourceParser.fs | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/Fantomas.Tests/KeepIndentInBranchTests.fs b/src/Fantomas.Tests/KeepIndentInBranchTests.fs index f6bb3fd434..f3578179c5 100644 --- a/src/Fantomas.Tests/KeepIndentInBranchTests.fs +++ b/src/Fantomas.Tests/KeepIndentInBranchTests.fs @@ -1770,3 +1770,63 @@ let updateModuleInImpl (ast: ParsedInput) (mdl: SynModuleOrNamespace) : ParsedIn ) |> ParsedInput.ImplFile """ + +[] +let ``short function application in if branch`` () = + formatSourceString + false + """ +let private parseModel (modelSrc: string) : Result = + if not (File.Exists(modelSrc)) then + Error [ sprintf "Provided modelSrc \"%s\" does not exist" modelSrc ] + else + let graph = new QueryableGraph() + graph.LoadFromFile(modelSrc, TurtleParser()) + + let xsdPath = + Path.Combine(Directory.GetCurrentDirectory(), "Some.xsd") + + let ontologyPath = + Path.Combine(Directory.GetCurrentDirectory(), "Some.ttl") + + let ontoGraph = new OntologyGraph() + FileLoader.Load(ontoGraph, ontologyPath) + + let validationErrors = + GraphValidation.validate xsdPath ontoGraph "http://company.com/meh" graph + + if List.isEmpty validationErrors then + Ok graph + else + Error validationErrors +""" + config + |> prepend newline + |> should + equal + """ +let private parseModel (modelSrc: string) : Result = + if not (File.Exists(modelSrc)) then + Error [ sprintf "Provided modelSrc \"%s\" does not exist" modelSrc ] + else + + let graph = new QueryableGraph() + graph.LoadFromFile(modelSrc, TurtleParser()) + + let xsdPath = + Path.Combine(Directory.GetCurrentDirectory(), "Some.xsd") + + let ontologyPath = + Path.Combine(Directory.GetCurrentDirectory(), "Some.ttl") + + let ontoGraph = new OntologyGraph() + FileLoader.Load(ontoGraph, ontologyPath) + + let validationErrors = + GraphValidation.validate xsdPath ontoGraph "http://company.com/meh" graph + + if List.isEmpty validationErrors then + Ok graph + else + Error validationErrors +""" diff --git a/src/Fantomas/SourceParser.fs b/src/Fantomas/SourceParser.fs index 28908b62d0..915ef71bc6 100644 --- a/src/Fantomas/SourceParser.fs +++ b/src/Fantomas/SourceParser.fs @@ -1721,7 +1721,7 @@ let private shouldNotIndentBranch e es = match e with | SimpleExpr _ | Sequential (_, _, true) - | App (SimpleExpr _, [ SimpleExpr _ ]) -> true + | App _ -> true | _ -> false let isLongElseBranch e =