File tree 2 files changed +14
-4
lines changed
Sources/SwiftFormatPrettyPrint
Tests/SwiftFormatPrettyPrintTests 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -355,9 +355,17 @@ public class PrettyPrinter {
355
355
lengths. append ( comment. length)
356
356
total += comment. length
357
357
358
- case . verbatim:
359
- lengths. append ( maxLineLength)
360
- total += maxLineLength
358
+ case . verbatim( let verbatim) :
359
+ var length : Int
360
+ if verbatim. lines. count > 1 {
361
+ length = maxLineLength
362
+ } else if verbatim. lines. count == 0 {
363
+ length = 0
364
+ } else {
365
+ length = verbatim. lines [ 0 ] . count
366
+ }
367
+ lengths. append ( length)
368
+ total += length
361
369
}
362
370
}
363
371
Original file line number Diff line number Diff line change @@ -3,20 +3,22 @@ public class StringTests: PrettyPrintTestCase {
3
3
let input =
4
4
"""
5
5
let a = " abc "
6
+ myFun( " Some string \\ (a + b) " )
6
7
let b = " A really long string that should not wrap "
7
8
let c = " A really long string with \\ (a + b) some expressions \\ (c + d) "
8
9
"""
9
10
10
11
let expected =
11
12
"""
12
13
let a = " abc "
14
+ myFun( " Some string \\ (a + b) " )
13
15
let b =
14
16
" A really long string that should not wrap "
15
17
let c =
16
18
" A really long string with \\ (a + b) some expressions \\ (c + d) "
17
19
18
20
"""
19
21
20
- assertPrettyPrintEqual ( input: input, expected: expected, linelength: 20 )
22
+ assertPrettyPrintEqual ( input: input, expected: expected, linelength: 35 )
21
23
}
22
24
}
You can’t perform that action at this time.
0 commit comments