Skip to content

Commit

Permalink
Long multiline prefix type name should be indented far enough. Fixes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Apr 30, 2021
1 parent 2470f7a commit 053c9bb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
33 changes: 33 additions & 0 deletions src/Fantomas.Tests/SignatureTests.fs
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
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
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

0 comments on commit 053c9bb

Please sign in to comment.