From e8b27f64f2c6da66d8194c505722b228090e8d80 Mon Sep 17 00:00:00 2001 From: nojaf Date: Fri, 30 Apr 2021 12:00:06 +0200 Subject: [PATCH] Long multiline prefix type name should be indented far enough. Fixes #1687. --- src/Fantomas.Tests/SignatureTests.fs | 33 ++++++++++++++++++++++ src/Fantomas.Tests/TypeDeclarationTests.fs | 2 +- src/Fantomas/CodePrinter.fs | 8 ++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/Fantomas.Tests/SignatureTests.fs b/src/Fantomas.Tests/SignatureTests.fs index d8b25cd806..5f00634516 100644 --- a/src/Fantomas.Tests/SignatureTests.fs +++ b/src/Fantomas.Tests/SignatureTests.fs @@ -1539,3 +1539,36 @@ type Foo = /// Hi! | Bar of int """ + +[] +let ``long multiline prefix type name should be indented far enough, 1687`` () = + formatSourceString + true + """ +namespace Foo + +type Bar = + member Hello : thing : XLongLongLongLongLongLongLongLong '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 'a, bool -> 'b, bool -> 'c, bool -> 'd, bool + -> ('e -> 'f) + -> 'g, ('h -> 'i) -> 'j> + * item : int list -> + LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong +""" diff --git a/src/Fantomas.Tests/TypeDeclarationTests.fs b/src/Fantomas.Tests/TypeDeclarationTests.fs index 136c243501..0e560e32e0 100644 --- a/src/Fantomas.Tests/TypeDeclarationTests.fs +++ b/src/Fantomas.Tests/TypeDeclarationTests.fs @@ -2815,7 +2815,7 @@ and [] Bar<'context, 'a> = if inner then let bv = unbox 'b>> + -> 'b>> bf this.InnerEquals af bf cont diff --git a/src/Fantomas/CodePrinter.fs b/src/Fantomas/CodePrinter.fs index ac3735529a..f5304c3f81 100644 --- a/src/Fantomas/CodePrinter.fs +++ b/src/Fantomas/CodePrinter.fs @@ -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