Skip to content

Commit 8fcddf2

Browse files
committed
Swap order of .close and .break around tuple exprs.
The close group and close break were in the wrong order, causing the right paren's length to not be included in the length of the open break before first tuple element. This allowed the open break between the left paren and first element to NOT fire, but later the close break before the right paren DOES FIRE due to line length.
1 parent e0a13b1 commit 8fcddf2

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ private final class TokenStreamCreator: SyntaxVisitor {
656656
} else if elementCount > 1 {
657657
// Tuples with more than one element are "true" tuples, and should indent as block structures.
658658
after(node.leftParen, tokens: .break(.open, size: 0), .open)
659-
before(node.rightParen, tokens: .close, .break(.close, size: 0))
659+
before(node.rightParen, tokens: .break(.close, size: 0), .close)
660660

661661
insertTokens(.break(.same), betweenElementsOf: node.elementList)
662662

Tests/SwiftFormatPrettyPrintTests/TupleDeclTests.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public class TupleDeclTests: PrettyPrintTestCase {
44
"""
55
let a = (1, 2, 3)
66
let a: (Int, Int, Int) = (1, 2, 3)
7+
let a = (1, 2, 3, 4, 5, 6, 70, 80, 90)
78
let a = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
89
let a = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
910
"""
@@ -12,6 +13,9 @@ public class TupleDeclTests: PrettyPrintTestCase {
1213
"""
1314
let a = (1, 2, 3)
1415
let a: (Int, Int, Int) = (1, 2, 3)
16+
let a = (
17+
1, 2, 3, 4, 5, 6, 70, 80, 90
18+
)
1519
let a = (
1620
1, 2, 3, 4, 5, 6, 7, 8, 9, 10
1721
)

0 commit comments

Comments
 (0)