Skip to content

Commit

Permalink
Comments in anonymous records (#2539)
Browse files Browse the repository at this point in the history
* Comments in anonymous records

* Add release notes for 5.0.3.

Co-authored-by: nojaf <[email protected]>
  • Loading branch information
edgarfgp and nojaf authored Sep 29, 2022
1 parent 6db23bd commit f1ec008
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
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

0 comments on commit f1ec008

Please sign in to comment.