Skip to content

Commit

Permalink
Allow right paren of enum case decl to be on the same line as the las…
Browse files Browse the repository at this point in the history
…t 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.
  • Loading branch information
dylansturg authored and allevato committed Apr 30, 2020
1 parent c7db906 commit a50d4fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
after(node.trailingComma, tokens: .break)

if let associatedValue = node.associatedValue {
arrangeParameterClause(associatedValue, forcesBreakBeforeRightParen: true)
arrangeParameterClause(associatedValue, forcesBreakBeforeRightParen: false)
}

return .visitChildren
Expand Down
5 changes: 2 additions & 3 deletions Tests/SwiftFormatPrettyPrintTests/EnumDeclTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,14 @@ final class EnumDeclTests: PrettyPrintTestCase {
fifth
case sixth(Int)
case seventh(
a: Int, b: Bool, c: Double
)
a: Int, b: Bool, c: Double)
}
"""

var config = Configuration()
config.lineBreakBeforeEachArgument = false
assertPrettyPrintEqual(input: input, expected: expected, linelength: 30, configuration: config)
assertPrettyPrintEqual(input: input, expected: expected, linelength: 31, configuration: config)
}

func testIndirectEnum() {
Expand Down

0 comments on commit a50d4fe

Please sign in to comment.