Skip to content

Commit 4491b93

Browse files
josh-degrawnojaf
andauthored
Fix stroustrup formatting issue with trivia (#2873)
* Fix stroustrup formatting issue with trivia * Update changelog --------- Co-authored-by: Florian Verdonck <[email protected]>
1 parent 27a224d commit 4491b93

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Changelog
22

3-
## [Unreleased]
3+
## [6.0.2] - 2023-05-05
44

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

89
## [6.0.1] - 2023-04-19
910

src/Fantomas.Core.Tests/Stroustrup/SynTypeDefnSimpleReprRecordTests.fs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ type MangaDexAtHomeResponse = {
296296
"""
297297

298298
[<Test>]
299-
let ``record interface declarations can break with Stroustrup enabled, 2787 `` () =
299+
let ``record interface declarations can break with Stroustrup enabled, 2787`` () =
300300
formatSourceString
301301
false
302302
"""
@@ -329,7 +329,7 @@ type UpdatedName = { PreviousName: string }
329329
"""
330330

331331
[<Test>]
332-
let ``record member declarations can break with Stroustrup enabled, 2787 `` () =
332+
let ``record member declarations can break with Stroustrup enabled, 2787`` () =
333333
formatSourceString
334334
false
335335
"""
@@ -354,3 +354,26 @@ type SomeEvent = {
354354
355355
type UpdatedName = { PreviousName: string }
356356
"""
357+
358+
[<Test>]
359+
let ``comment above record bracket breaks formatting when Stroustrup enabled, 2871`` () =
360+
formatSourceString
361+
false
362+
"""
363+
type Event =
364+
// TODO: Add LulaSafe conclusion and scores per assessment
365+
{
366+
Metadata: AssessmentMetadata
367+
}
368+
"""
369+
config
370+
|> prepend newline
371+
|> should
372+
equal
373+
"""
374+
type Event =
375+
// TODO: Add LulaSafe conclusion and scores per assessment
376+
{
377+
Metadata: AssessmentMetadata
378+
}
379+
"""

src/Fantomas.Core/CodePrinter.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3375,7 +3375,7 @@ let genTypeDefn (td: TypeDefn) =
33753375
let size = getRecordSize ctx node.Fields
33763376
let short = bodyExpr size
33773377

3378-
if ctx.Config.IsStroustrupStyle then
3378+
if ctx.Config.IsStroustrupStyle && not node.OpeningBrace.HasContentBefore then
33793379
(sepSpace +> short) ctx
33803380
else
33813381
isSmallExpression size short (indentSepNlnUnindent short) ctx

0 commit comments

Comments
 (0)