diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c272b0db7..61d415fd8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [5.1.0-alpha-007] - 2022-10-14 + +### Changed +* Revert multiline alternative for prefix types. [#2582](https://github.com/fsprojects/fantomas/pull/2582) + ## [5.1.0-alpha-006] - 2022-10-14 ### Changed diff --git a/src/Fantomas.Core.Tests/ClassTests.fs b/src/Fantomas.Core.Tests/ClassTests.fs index add95b86d1..370ffd1b0c 100644 --- a/src/Fantomas.Core.Tests/ClassTests.fs +++ b/src/Fantomas.Core.Tests/ClassTests.fs @@ -1248,10 +1248,8 @@ module rec Xterm [] type Terminal = abstract onKey: - IEvent< - {| key: string - domEvent: KeyboardEvent |} - > with get, set + IEvent<{| key: string + domEvent: KeyboardEvent |}> with get, set abstract onLineFeed: IEvent with get, set """ diff --git a/src/Fantomas.Core.Tests/NewlineBetweenTypeDefinitionAndMembersTests.fs b/src/Fantomas.Core.Tests/NewlineBetweenTypeDefinitionAndMembersTests.fs index 1c61588aa5..2a2609abc0 100644 --- a/src/Fantomas.Core.Tests/NewlineBetweenTypeDefinitionAndMembersTests.fs +++ b/src/Fantomas.Core.Tests/NewlineBetweenTypeDefinitionAndMembersTests.fs @@ -421,10 +421,10 @@ let ``multiline abstract member without constraints, 2175`` () = type FuseSortFunctionItem = abstract Item: key: string -> - U2< - {| ``$``: string |}, - ResizeArray<{| ``$``: string; idx: float |}> - > with get, set + U2<{| ``$``: string |}, ResizeArray<{| ``$``: + string + idx: + float |}>> with get, set abstract X: int """ diff --git a/src/Fantomas.Core.Tests/SignatureTests.fs b/src/Fantomas.Core.Tests/SignatureTests.fs index d5f818af91..9f765b01f3 100644 --- a/src/Fantomas.Core.Tests/SignatureTests.fs +++ b/src/Fantomas.Core.Tests/SignatureTests.fs @@ -1606,14 +1606,9 @@ namespace Foo type Bar = member Hello : thing : - XLongLongLongLongLongLongLongLong< - bool -> 'a, - bool -> 'b, - bool -> 'c, - bool -> 'd, - bool -> ('e -> 'f) -> 'g, - ('h -> 'i) -> 'j - > * + XLongLongLongLongLongLongLongLong 'a, bool -> 'b, bool -> 'c, bool -> 'd, bool -> ('e -> 'f) -> 'g, ('h + -> 'i) + -> 'j> * item : int list -> LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLong """ diff --git a/src/Fantomas.Core.Tests/TypeAnnotationTests.fs b/src/Fantomas.Core.Tests/TypeAnnotationTests.fs index b401f7d3bf..a661cf5ebb 100644 --- a/src/Fantomas.Core.Tests/TypeAnnotationTests.fs +++ b/src/Fantomas.Core.Tests/TypeAnnotationTests.fs @@ -77,11 +77,56 @@ type X = equal """ type X = - Teq< - int, - list int, - System.DateTime array, - // - int - > + Teq +""" + +[] +let ``multiline app type`` () = + formatSourceString + false + """ +type CancellableTaskResultBuilderBase with + + [] + static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error + when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter) + and ^Awaiter :> ICriticalNotifyCompletion + and ^Awaiter: (member get_IsCompleted: unit -> bool) + and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)> + ( + sm: + byref< + ResumableStateMachine< + CancellableTaskResultStateMachineData<'TOverall, 'Error> + > + >, + task: CancellationToken -> ^TaskLike, + continuation: + ('TResult1 -> CancellableTaskResultCode<'TOverall, 'Error, 'TResult2>) + ) : bool = true +""" + { config with MaxLineLength = 80 } + |> prepend newline + |> should + equal + """ +type CancellableTaskResultBuilderBase with + + [] + static member inline BindDynamic< ^TaskLike, 'TResult1, 'TResult2, ^Awaiter, 'TOverall, 'Error + when ^TaskLike: (member GetAwaiter: unit -> ^Awaiter) + and ^Awaiter :> ICriticalNotifyCompletion + and ^Awaiter: (member get_IsCompleted: unit -> bool) + and ^Awaiter: (member GetResult: unit -> Result<'TResult1, 'Error>)> + ( + sm: + byref>>, + task: CancellationToken -> ^TaskLike, + continuation: + ('TResult1 + -> CancellableTaskResultCode<'TOverall, 'Error, 'TResult2>) + ) : bool = + true """ diff --git a/src/Fantomas.Core.Tests/TypeDeclarationTests.fs b/src/Fantomas.Core.Tests/TypeDeclarationTests.fs index 769bf38f72..28f7fddb67 100644 --- a/src/Fantomas.Core.Tests/TypeDeclarationTests.fs +++ b/src/Fantomas.Core.Tests/TypeDeclarationTests.fs @@ -2874,10 +2874,8 @@ and [] Bar<'context, 'a> = (fun inner -> if inner then let bv = - unbox 'b - >> + unbox 'b>> bf this.InnerEquals af bf cont diff --git a/src/Fantomas.Core/CodePrinter.fs b/src/Fantomas.Core/CodePrinter.fs index c2522ea5e1..863bf2adae 100644 --- a/src/Fantomas.Core/CodePrinter.fs +++ b/src/Fantomas.Core/CodePrinter.fs @@ -3691,12 +3691,9 @@ and genPrefixTypes +> genTriviaForOption greaterNodeType greaterRange !- " >") ctx | t :: _ -> - let shortTs = col sepComma ts genType - let longTs = indentSepNlnUnindent (col (sepComma +> sepNln) ts genType) +> sepNln - (genTriviaForOption lessNodeType lessRange !- "<" +> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t - +> expressionFitsOnRestOfLine shortTs longTs + +> col sepComma ts genType +> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t +> genTriviaForOption greaterNodeType greaterRange !- ">") ctx