Skip to content

Commit b0ac22e

Browse files
committed
Merge branch 'main' into 6.0/merge-main-2024-05-01
2 parents 1d3f101 + 366da31 commit b0ac22e

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Documentation/RuleDocumentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Use the rules below in the `rules` block of your `.swift-format`
66
configuration file, as described in
7-
[Configuration](Documentation/Configuration.md). All of these rules can be
7+
[Configuration](Configuration.md). All of these rules can be
88
applied in the linter, but only some of them can format your source code
99
automatically.
1010

Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,14 +1350,6 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
13501350
}
13511351

13521352
override func visit(_ node: EnumCaseParameterClauseSyntax) -> SyntaxVisitorContinueKind {
1353-
// Prioritize keeping ") throws -> <return_type>" together. We can only do this if the function
1354-
// has arguments.
1355-
if !node.parameters.isEmpty && config.prioritizeKeepingFunctionOutputTogether {
1356-
// Due to visitation order, this .open corresponds to a .close added in FunctionDeclSyntax
1357-
// or SubscriptDeclSyntax.
1358-
before(node.rightParen, tokens: .open)
1359-
}
1360-
13611353
return .visitChildren
13621354
}
13631355

Tests/SwiftFormatTests/PrettyPrint/EnumDeclTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,4 +559,16 @@ final class EnumDeclTests: PrettyPrintTestCase {
559559
let input = "enum Foo { var bar: Int }"
560560
assertPrettyPrintEqual(input: input, expected: input + "\n", linelength: 50)
561561
}
562+
563+
func testEnumWithPrioritizeKeepingFunctionOutputTogetherFlag() {
564+
let input = """
565+
enum Error {
566+
case alreadyOpen(Int)
567+
}
568+
569+
"""
570+
var config = Configuration.forTesting
571+
config.prioritizeKeepingFunctionOutputTogether = true
572+
assertPrettyPrintEqual(input: input, expected: input, linelength: 50, configuration: config)
573+
}
562574
}

0 commit comments

Comments
 (0)