File tree 2 files changed +13
-1
lines changed
Sources/SwiftFormatPrettyPrint
Tests/SwiftFormatPrettyPrintTests
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -1420,7 +1420,9 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor {
1420
1420
}
1421
1421
1422
1422
override func visit( _ node: TryExprSyntax ) -> SyntaxVisitorContinueKind {
1423
- before ( node. expression. firstToken, tokens: . break)
1423
+ before (
1424
+ node. expression. firstToken,
1425
+ tokens: . break( . continue, newlines: . elective( ignoresDiscretionary: true ) ) )
1424
1426
1425
1427
// Check for an anchor token inside of the expression to group with the try keyword.
1426
1428
if let anchorToken = findTryExprConnectingToken ( inExpr: node. expression) {
Original file line number Diff line number Diff line change @@ -236,6 +236,8 @@ final class TryCatchTests: PrettyPrintTestCase {
236
236
let input =
237
237
"""
238
238
let aVeryLongArgumentName = try foo.bar()
239
+ let aVeryLongArgumentName = try
240
+ foo.bar()
239
241
let aVeryLongArgumentName = try? foo.bar()
240
242
let abc = try foo.baz().quxxe(a, b, c).bar()
241
243
let abc = try foo
@@ -246,10 +248,15 @@ final class TryCatchTests: PrettyPrintTestCase {
246
248
let abc = try foo.baz().quxxe(a, b, c).bar[0]
247
249
let abc = try foo
248
250
.baz().quxxe(a, b, c).bar[0]
251
+ let abc = try
252
+ foo
253
+ .baz().quxxe(a, b, c).bar[0]
249
254
"""
250
255
251
256
let expected =
252
257
"""
258
+ let aVeryLongArgumentName =
259
+ try foo.bar()
253
260
let aVeryLongArgumentName =
254
261
try foo.bar()
255
262
let aVeryLongArgumentName =
@@ -268,6 +275,9 @@ final class TryCatchTests: PrettyPrintTestCase {
268
275
let abc =
269
276
try foo
270
277
.baz().quxxe(a, b, c).bar[0]
278
+ let abc =
279
+ try foo
280
+ .baz().quxxe(a, b, c).bar[0]
271
281
272
282
"""
273
283
You can’t perform that action at this time.
0 commit comments