Skip to content

Commit 0bf9b8e

Browse files
committed
Fix spacing after labeled tuple colons.
1 parent e5f5dd9 commit 0bf9b8e

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ private final class TokenStreamCreator: SyntaxVisitor {
117117

118118
override func visit(_ node: TupleElementSyntax) {
119119
before(node.firstToken, tokens: .open)
120+
after(node.colon, tokens: .break)
120121
after(node.lastToken, tokens: .close)
121122
super.visit(node)
122123
}

Tests/SwiftFormatPrettyPrintTests/TupleDeclTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,21 @@ public class TupleDeclTests: PrettyPrintTestCase {
4949

5050
assertPrettyPrintEqual(input: input, expected: expected, linelength: 37)
5151
}
52+
53+
public func testLabeledTuples() {
54+
let input =
55+
"""
56+
let a = (A: var1, B: var2)
57+
var b: (A: Int, B: Double)
58+
"""
59+
60+
let expected =
61+
"""
62+
let a = (A: var1, B: var2)
63+
var b: (A: Int, B: Double)
64+
65+
"""
66+
67+
assertPrettyPrintEqual(input: input, expected: expected, linelength: 30)
68+
}
5269
}

0 commit comments

Comments
 (0)