Skip to content

Commit a50d4fe

Browse files
dylansturgallevato
authored andcommitted
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 c7db906 commit a50d4fe

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
11901190
after(node.trailingComma, tokens: .break)
11911191

11921192
if let associatedValue = node.associatedValue {
1193-
arrangeParameterClause(associatedValue, forcesBreakBeforeRightParen: true)
1193+
arrangeParameterClause(associatedValue, forcesBreakBeforeRightParen: false)
11941194
}
11951195

11961196
return .visitChildren

Tests/SwiftFormatPrettyPrintTests/EnumDeclTests.swift

+2-3
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)