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

Fix multiline implicit constructor #2637

Merged
merged 2 commits into from
Dec 4, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Fixed
* Regression around `let ... in` in multiline infix application. [#2633](https://github.com/fsprojects/fantomas/pull/2633)
* Improve TypeDefn. [#2636](https://github.com/fsprojects/fantomas/pull/2636)
* Trivia before equals in multiline implicit type constructor. [#2637](https://github.com/fsprojects/fantomas/pull/2637)

## [5.2.0-alpha-001] - 2022-11-30

Expand Down
29 changes: 29 additions & 0 deletions src/Fantomas.Core.Tests/DallasTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1726,3 +1726,32 @@ let ``type alias with trivia`` () =
"""
(* 1 *) type (* 2 *) A (* 3 *) = (* 4 *) int (* 5 *)
"""

[<Test>]
let ``trivia before equals in multiline implicit constructor`` () =
formatSourceString
false
"""
type TypeDefnUnionNode
(
typeNameNode,
accessibility: SingleTextNode option,
unionCases: UnionCaseNode list,
members: MemberDefn list,
range
)

=
inherit NodeBase(range)
"""
config
|> prepend newline
|> should
equal
"""
type TypeDefnUnionNode
(typeNameNode, accessibility: SingleTextNode option, unionCases: UnionCaseNode list, members: MemberDefn list, range)

=
inherit NodeBase(range)
"""
2 changes: 1 addition & 1 deletion src/Fantomas.Core.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1779,7 +1779,7 @@ type Meh =
* timeout: int ->
obj
"""
{ config with MaxLineLength = 5 }
{ config with MaxLineLength = 12 }
|> prepend newline
|> should
equal
Expand Down
5 changes: 4 additions & 1 deletion src/Fantomas.Core/CodePrinter2.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3189,7 +3189,10 @@ let genTypeDefn (td: TypeDefn) =
if isMulti && ctx.Config.AlternativeLongMemberDefinitions then
(optSingle genSingleTextNode typeName.EqualsToken) ctx
else
(sepSpace +> optSingle genSingleTextNode typeName.EqualsToken) ctx)
(sepSpaceOrIndentAndNlnIfExpressionExceedsPageWidth (
optSingle genSingleTextNode typeName.EqualsToken
))
ctx)
|> genNode typeName

let members = typeDefnNode.Members
Expand Down
4 changes: 1 addition & 3 deletions src/Fantomas.Core/SyntaxOak.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2281,9 +2281,7 @@ type TypeDefnUnionNode
unionCases: UnionCaseNode list,
members: MemberDefn list,
range
)

=
) =
inherit NodeBase(range)

override this.Children =
Expand Down