Skip to content

Commit

Permalink
Print trivia for SynExpr.LongIdent. Fixes #1080. (#1081)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf authored Sep 4, 2020
1 parent 573b009 commit 82a6987
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Fantomas.Tests/LongIdentWithDotsTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,21 @@ let variable =
|> Result.okValue)
.Value
"""

[<Test>]
let ``preserve comment before SynExpr.LongIdent, 1080`` () =
formatSourceString false """
let shrinkInput input =
match toSynExprs input with
| [] ->
//stdout.WriteLine("Can't shrink {0} further.", sprintf "%A" input)
Seq.empty
""" config
|> prepend newline
|> should equal """
let shrinkInput input =
match toSynExprs input with
| [] ->
//stdout.WriteLine("Can't shrink {0} further.", sprintf "%A" input)
Seq.empty
"""
1 change: 1 addition & 0 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,7 @@ and genExpr astContext synExpr =
| SynExpr.Assert _ -> genTriviaFor SynExpr_Assert synExpr.Range
| SynExpr.While _ -> genTriviaFor SynExpr_While synExpr.Range
| SynExpr.MatchLambda _ -> genTriviaFor SynExpr_MatchLambda synExpr.Range
| SynExpr.LongIdent _ -> genTriviaFor SynExpr_LongIdent synExpr.Range
| _ -> id)

and genMultilineRecordInstance
Expand Down

0 comments on commit 82a6987

Please sign in to comment.