Skip to content

Commit

Permalink
Keep indent for newline infix application. Fixes #1768. (#1770)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Jun 6, 2021
1 parent c557f79 commit 2890b4a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/Fantomas.Tests/KeepIndentInBranchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1728,3 +1728,45 @@ let mapOperationToWebPart (operation: OpenApiOperationDescription) : SynExpr =
infixFish verb route
"""

[<Test>]
let ``multiline infix application, 1768`` () =
formatSourceString
false
"""
let updateModuleInImpl (ast: ParsedInput) (mdl: SynModuleOrNamespace) : ParsedInput =
match ast with
| ParsedInput.SigFile _ -> ast
| ParsedInput.ImplFile _ ->
ParsedImplFileInput(
fileName,
isScript,
qualifiedNameOfFile,
scopedPragmas,
hashDirectives,
[ mdl ],
isLastAndCompiled
)
|> ParsedInput.ImplFile
"""
config
|> prepend newline
|> should
equal
"""
let updateModuleInImpl (ast: ParsedInput) (mdl: SynModuleOrNamespace) : ParsedInput =
match ast with
| ParsedInput.SigFile _ -> ast
| ParsedInput.ImplFile _ ->
ParsedImplFileInput(
fileName,
isScript,
qualifiedNameOfFile,
scopedPragmas,
hashDirectives,
[ mdl ],
isLastAndCompiled
)
|> ParsedInput.ImplFile
"""
3 changes: 2 additions & 1 deletion src/Fantomas/SourceParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,8 @@ let private shouldNotIndentBranch e es =
| Sequential _
| Match _
| TryWith _
| App (_, [ ObjExpr _ ]) -> true
| App (_, [ ObjExpr _ ])
| NewlineInfixApp (_, _, AppParenTupleArg _, _) -> true
| _ -> false

List.forall isShortIfBranch es
Expand Down

0 comments on commit 2890b4a

Please sign in to comment.