From 2dd68a061c5958d52dbb62e89eede2af9be1cca4 Mon Sep 17 00:00:00 2001 From: Shawn Hyam Date: Mon, 29 Apr 2024 10:44:24 -0400 Subject: [PATCH] Remove check for prioritizeKeepingFunctionOutputTogether on enum decl. --- .../SwiftFormat/PrettyPrint/TokenStreamCreator.swift | 8 -------- .../SwiftFormatTests/PrettyPrint/EnumDeclTests.swift | 12 ++++++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index 1023d886..0b96cf02 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -1350,14 +1350,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { } override func visit(_ node: EnumCaseParameterClauseSyntax) -> SyntaxVisitorContinueKind { - // Prioritize keeping ") throws -> " together. We can only do this if the function - // has arguments. - if !node.parameters.isEmpty && config.prioritizeKeepingFunctionOutputTogether { - // Due to visitation order, this .open corresponds to a .close added in FunctionDeclSyntax - // or SubscriptDeclSyntax. - before(node.rightParen, tokens: .open) - } - return .visitChildren } diff --git a/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift b/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift index 675d75ed..1561d8e8 100644 --- a/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift +++ b/Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift @@ -559,4 +559,16 @@ final class EnumDeclTests: PrettyPrintTestCase { let input = "enum Foo { var bar: Int }" assertPrettyPrintEqual(input: input, expected: input + "\n", linelength: 50) } + + func testEnumWithPrioritizeKeepingFunctionOutputTogetherFlag() { + let input = """ + enum Error { + case alreadyOpen(Int) + } + + """ + var config = Configuration.forTesting + config.prioritizeKeepingFunctionOutputTogether = true + assertPrettyPrintEqual(input: input, expected: input, linelength: 50, configuration: config) + } }