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

Long multiline prefix type name should be indented far enough. #1690

Merged
merged 1 commit into from
Apr 30, 2021
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
33 changes: 33 additions & 0 deletions src/Fantomas.Tests/SignatureTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1539,3 +1539,36 @@ type Foo =
/// Hi!
| Bar of int
"""

[<Test>]
let ``long multiline prefix type name should be indented far enough, 1687`` () =
formatSourceString
true
"""
namespace Foo

type Bar =
member Hello : thing : XLongLongLongLongLongLongLongLong<bool -> 'a, bool -> 'b, bool -> 'c, bool -> 'd, bool -> ('e -> 'f) -> 'g, ('h -> 'i) -> 'j> * item : int list -> LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong
"""
{ config with
SpaceBeforeUppercaseInvocation = true
SpaceBeforeClassConstructor = true
SpaceBeforeMember = true
SpaceBeforeColon = true
SpaceBeforeSemicolon = true
AlignFunctionSignatureToIndentation = true
AlternativeLongMemberDefinitions = true }
|> prepend newline
|> should
equal
"""
namespace Foo

type Bar =
member Hello :
thing : XLongLongLongLongLongLongLongLong<bool -> 'a, bool -> 'b, bool -> 'c, bool -> 'd, bool
-> ('e -> 'f)
-> 'g, ('h -> 'i) -> 'j>
* item : int list ->
LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong
"""
2 changes: 1 addition & 1 deletion src/Fantomas.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2815,7 +2815,7 @@ and [<CustomEquality ; NoComparison>] Bar<'context, 'a> =
if inner then
let bv =
unbox<Foo<'innerContextLongLongLong, 'bb
-> 'b>>
-> 'b>>
bf

this.InnerEquals af bf cont
Expand Down
8 changes: 5 additions & 3 deletions src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4301,9 +4301,11 @@ and genPrefixTypes astContext node (range: Range) ctx =
ctx
| t :: _ ->
(!- "<"
+> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t
+> col sepComma node (genType astContext false)
+> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t
+> atCurrentColumnIndent (
addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t
+> col sepComma node (genType astContext false)
+> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t
)
+> tokN range GREATER (!- ">"))
ctx

Expand Down