Skip to content

Commit 90cb1e8

Browse files
committed
Require the token following yield to be on the same line.
1 parent 7cd9ff3 commit 90cb1e8

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Sources/SwiftFormatPrettyPrint/TokenStreamCreator.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,9 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
764764
}
765765

766766
override func visit(_ node: YieldStmtSyntax) -> SyntaxVisitorContinueKind {
767-
after(node.yieldKeyword, tokens: .break)
767+
// As of https://github.com/apple/swift-syntax/pull/895, the token following a `yield` keyword
768+
// *must* be on the same line, so we cannot break here.
769+
after(node.yieldKeyword, tokens: .space)
768770
return .visitChildren
769771
}
770772

Tests/SwiftFormatPrettyPrintTests/YieldStmtTests.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@ final class YieldStmtTests: PrettyPrintTestCase {
1717
"""
1818
var foo: Int {
1919
_read {
20-
yield
21-
1234567890
20+
yield 1234567890
2221
}
2322
_modify {
2423
var someLongVariable =
2524
0
26-
yield
27-
&someLongVariable
25+
yield &someLongVariable
2826
}
2927
}
3028

0 commit comments

Comments
 (0)