Skip to content

Commit

Permalink
Fix stroustrup formatting issue with trivia (#2873)
Browse files Browse the repository at this point in the history
* Fix stroustrup formatting issue with trivia

* Update changelog

---------

Co-authored-by: Florian Verdonck <[email protected]>
  • Loading branch information
josh-degraw and nojaf authored May 5, 2023
1 parent 27a224d commit 4491b93
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Changelog

## [Unreleased]
## [6.0.2] - 2023-05-05

### Fixed
* Incorrect indentation of compiler-conditional accessibility modifier for module definition. [#2867](https://github.com/fsprojects/fantomas/issues/2867)
* Comment above the record bracket beaks formatting when MultilineBracketStyle is Stroustrup. [#2871](https://github.com/fsprojects/fantomas/issues/2871)

## [6.0.1] - 2023-04-19

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ type MangaDexAtHomeResponse = {
"""

[<Test>]
let ``record interface declarations can break with Stroustrup enabled, 2787 `` () =
let ``record interface declarations can break with Stroustrup enabled, 2787`` () =
formatSourceString
false
"""
Expand Down Expand Up @@ -329,7 +329,7 @@ type UpdatedName = { PreviousName: string }
"""

[<Test>]
let ``record member declarations can break with Stroustrup enabled, 2787 `` () =
let ``record member declarations can break with Stroustrup enabled, 2787`` () =
formatSourceString
false
"""
Expand All @@ -354,3 +354,26 @@ type SomeEvent = {
type UpdatedName = { PreviousName: string }
"""

[<Test>]
let ``comment above record bracket breaks formatting when Stroustrup enabled, 2871`` () =
formatSourceString
false
"""
type Event =
// TODO: Add LulaSafe conclusion and scores per assessment
{
Metadata: AssessmentMetadata
}
"""
config
|> prepend newline
|> should
equal
"""
type Event =
// TODO: Add LulaSafe conclusion and scores per assessment
{
Metadata: AssessmentMetadata
}
"""
2 changes: 1 addition & 1 deletion src/Fantomas.Core/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3375,7 +3375,7 @@ let genTypeDefn (td: TypeDefn) =
let size = getRecordSize ctx node.Fields
let short = bodyExpr size

if ctx.Config.IsStroustrupStyle then
if ctx.Config.IsStroustrupStyle && not node.OpeningBrace.HasContentBefore then
(sepSpace +> short) ctx
else
isSmallExpression size short (indentSepNlnUnindent short) ctx
Expand Down

0 comments on commit 4491b93

Please sign in to comment.