Skip to content

Commit

Permalink
Consider all function applications as short branch. Fixes #1779. (#1784)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Jun 23, 2021
1 parent d9df0c8 commit 2d2b0ca
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
60 changes: 60 additions & 0 deletions src/Fantomas.Tests/KeepIndentInBranchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1770,3 +1770,63 @@ let updateModuleInImpl (ast: ParsedInput) (mdl: SynModuleOrNamespace) : ParsedIn
)
|> ParsedInput.ImplFile
"""

[<Test>]
let ``short function application in if branch`` () =
formatSourceString
false
"""
let private parseModel (modelSrc: string) : Result<MyReturnType, string list> =
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<MyReturnType, string list> =
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
"""
2 changes: 1 addition & 1 deletion src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 2d2b0ca

Please sign in to comment.