Skip to content

Commit

Permalink
implement new line for brace
Browse files Browse the repository at this point in the history
  • Loading branch information
miyashi committed Mar 21, 2020
1 parent 1995ab4 commit f423789
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/Core/Formatter/MultilineFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,20 @@ class MultilineFormatter: PrettyFormatter {
func objectString(
typeName: String, fields: [(String, String)]
) -> String {
let prefix = "\(typeName)("
let body: String

if fields.count == 1, let field = fields.first {
body = "\(field.0): \(field.1)"
} else {
body = fields
.map { label, value in "\(label): \(value.indentTail(size: "\(label): ".count))" }
.joined(separator: ",\n")
.indentTail(size: prefix.count)
.indentTail(size: "\(typeName)".count)
}

return prefix + body + ")"
return """
\(typeName)(
\(body)
)
"""
}
}

0 comments on commit f423789

Please sign in to comment.