Skip to content

Commit 558e190

Browse files
committed
Allow right paren of enum case decl to be on the same line as the last param.
When enum cases have associated values, these are similar to function params. The right paren is allowed to stay on the same line for function params, and this makes enum cases consistent. The break allows discretionary line breaks.
1 parent 1691699 commit 558e190

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
11861186
after(node.trailingComma, tokens: .break)
11871187

11881188
if let associatedValue = node.associatedValue {
1189-
arrangeParameterClause(associatedValue, forcesBreakBeforeRightParen: true)
1189+
arrangeParameterClause(associatedValue, forcesBreakBeforeRightParen: false)
11901190
}
11911191

11921192
return .visitChildren

Tests/SwiftFormatPrettyPrintTests/EnumDeclTests.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,14 @@ final class EnumDeclTests: PrettyPrintTestCase {
115115
fifth
116116
case sixth(Int)
117117
case seventh(
118-
a: Int, b: Bool, c: Double
119-
)
118+
a: Int, b: Bool, c: Double)
120119
}
121120
122121
"""
123122

124123
var config = Configuration()
125124
config.lineBreakBeforeEachArgument = false
126-
assertPrettyPrintEqual(input: input, expected: expected, linelength: 30, configuration: config)
125+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 31, configuration: config)
127126
}
128127

129128
func testIndirectEnum() {

0 commit comments

Comments
 (0)