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

Comments in anonymous records #2539

Merged
merged 2 commits into from
Sep 29, 2022
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [5.0.3] - 2022-09-29

### Fixed
* Comments in anonymous record deleted after formatting. [#2538](https://github.com/fsprojects/fantomas/issues/2538)

## [5.0.2] - 2022-09-22

### Fixed
Expand Down
19 changes: 19 additions & 0 deletions src/Fantomas.Core.Tests/CommentTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2515,3 +2515,22 @@ type X =
// The 'Cancel' member
(System.IAsyncResult -> unit)
"""

[<Test>]
let ``comments in anonymous records, 2538`` () =
formatSourceString
false
"""
let Anonymous =
{| FontFamily = 700 // font-weight
FontSize = 48. |} // font-weight
"""
config
|> prepend newline
|> should
equal
"""
let Anonymous =
{| FontFamily = 700 // font-weight
FontSize = 48. |} // font-weight
"""
3 changes: 2 additions & 1 deletion src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2565,7 +2565,8 @@ and genMultilineAnonRecord (isStruct: bool) fields copyInfo (astContext: ASTCont
addFixedSpaces targetColumn
+> atCurrentColumn (enterNodeFor SynExpr_AnonRecd_Field range +> genIdent ident)
+> genEq SynExpr_AnonRecd_Field_Equals eq
+> expr)
+> expr
+> leaveNodeFor SynExpr_AnonRecd_Field range)
+> sepCloseAnonRecd)
ctx

Expand Down