Skip to content

Commit

Permalink
Print trivia between empty dual list Elmish children. Fixes #1179. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Apr 23, 2021
1 parent 4d73011 commit 728e31e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 19 additions & 0 deletions src/Fantomas.Tests/ElmishTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1440,3 +1440,22 @@ let private App () =
exportDefault App
"""

[<Test>]
let ``comment inside empty elmish children, 1179`` () =
formatSourceString
false
"""
a [] [
// def
]
"""
config
|> prepend newline
|> should
equal
"""
a [] [
// def
]
"""
8 changes: 3 additions & 5 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,11 +1098,9 @@ and genExpr astContext synExpr ctx =
(if isArray then BAR_RBRACK else RBRACK)

match children with
| [] when (not isArray) ->
sepOpenLFixed
+> sepCloseLFixed
+> leaveNodeTokenByName childrenRange RBRACK
| [] when isArray -> sepOpenAFixed +> sepCloseAFixed
| [] ->
tokN openingTokenRange openTokenType (ifElse isArray sepOpenAFixed sepOpenLFixed)
+> tokN closingTokenRange closingTokenType (ifElse isArray sepCloseAFixed sepCloseLFixed)
| [ singleChild ] ->
if isShort then
tokN openingTokenRange openTokenType (ifElse isArray sepOpenA sepOpenL)
Expand Down

0 comments on commit 728e31e

Please sign in to comment.