Skip to content

Commit

Permalink
KeepIndentInBranch for value bindings. Fixes fsprojects#1728.
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed May 19, 2021
1 parent 54e19d9 commit 4c9def8
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
47 changes: 47 additions & 0 deletions src/Fantomas.Tests/KeepIndentInBranchTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1540,3 +1540,50 @@ let x y =
let ipv4 = string result.["ipv4"]
None
"""

[<Test>]
let ``value binding, 1728`` () =
formatSourceString
false
"""
let x =
if not (
result.HasResultsFor(
[ "label"
"ipv4"
"macAddress"
"medium"
"manufacturer" ]
)
) then
None
else
let label = string result.["label"]
let ipv4 = string result.["ipv4"]
None
"""
config
|> prepend newline
|> should
equal
"""
let x =
if
not (
result.HasResultsFor(
[ "label"
"ipv4"
"macAddress"
"medium"
"manufacturer" ]
)
)
then
None
else
let label = string result.["label"]
let ipv4 = string result.["ipv4"]
None
"""
4 changes: 2 additions & 2 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5305,12 +5305,12 @@ and genSynBindingValue
+> genReturnType
+> (fun ctx -> genEqualsInBinding (equalsRange ctx) ctx))
(fun isMultiline ctx ->
let short = genExpr astContext e
let short = genExprKeepIndentInBranch astContext e

let long =
indent
+> sepNln
+> genExpr astContext e
+> genExprKeepIndentInBranch astContext e
+> unindent

if isMultiline then
Expand Down

0 comments on commit 4c9def8

Please sign in to comment.