Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not duplicate comment #1914

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions src/Fantomas.Tests/CommentTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1558,3 +1558,44 @@ Host

//
"""

[<Test>]
let ``comment after bracket in record should not be duplicated in computation expression, 1912`` () =
formatSourceString
false
"""
type TorDirectory =
private
{
NetworkStatus: NetworkStatusDocument
}

static member Bootstrap (nodeEndPoint: IPEndPoint) =
async {
return
{
TorDirectory.NetworkStatus =
NetworkStatusDocument.Parse consensusStr
ServerDescriptors = Map.empty
// comment
}
}
"""
config
|> prepend newline
|> should
equal
"""
type TorDirectory =
private
{ NetworkStatus: NetworkStatusDocument }

static member Bootstrap(nodeEndPoint: IPEndPoint) =
async {
return
{ TorDirectory.NetworkStatus = NetworkStatusDocument.Parse consensusStr
ServerDescriptors = Map.empty
// comment
}
}
"""
8 changes: 7 additions & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1397,7 +1397,13 @@ and genExpr astContext synExpr ctx =
(genExpr astContext e +> sepCloseS)
(genExpr astContext e
+> unindent
+> enterNodeTokenByName synExpr.Range RBRACE
+> (fun ctx ->
let closingBraceRange =
ctx.MkRangeWith
(synExpr.Range.EndLine, synExpr.Range.EndColumn - 1)
(synExpr.Range.EndLine, synExpr.Range.EndColumn)

enterNodeTokenByName closingBraceRange RBRACE ctx)
+> sepNlnUnlessLastEventIsNewline
+> sepCloseSFixed))

Expand Down