File tree Expand file tree Collapse file tree 3 files changed +6
-2
lines changed
Sources/SwiftFormat/PrettyPrint
Tests/SwiftFormatTests/PrettyPrint Expand file tree Collapse file tree 3 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -67,9 +67,9 @@ struct Comment {
67
67
68
68
switch kind {
69
69
case .line, .docLine:
70
+ self.length = text.count
70
71
self.text = [text]
71
72
self.text[0].removeFirst(kind.prefixLength)
72
- self.length = self.text.reduce(0, { $0 + $1.count + kind.prefixLength + 1 })
73
73
74
74
case .block, .docBlock:
75
75
var fulltext: String = text
Original file line number Diff line number Diff line change @@ -558,7 +558,9 @@ public class PrettyPrinter {
558
558
/// Indicates whether the current line can fit a string of the given length. If no length
559
559
/// is given, it indicates whether the current line can accomodate *any* text.
560
560
private func canFit( _ length: Int = 1 ) -> Bool {
561
+ // print("\(length)")
561
562
let spaceRemaining = configuration. lineLength - outputBuffer. column
563
+ // print("let \(spaceRemaining) = \(configuration.lineLength) - \(outputBuffer.column)")
562
564
return outputBuffer. isAtStartOfLine || length <= spaceRemaining
563
565
}
564
566
Original file line number Diff line number Diff line change @@ -985,7 +985,8 @@ final class CommentTests: PrettyPrintTestCase {
985
985
assertPrettyPrintEqual (
986
986
input: """
987
987
import veryveryverylongmodulenameherebecauseitistypical // special sentinel comment
988
-
988
+
989
+ let x // this comment should line up with 45
989
990
func fooBarBazRunningOutOfIdeas() { 1️⃣// comment that needs to move
990
991
if foo { // comment is fine
991
992
}
@@ -995,6 +996,7 @@ final class CommentTests: PrettyPrintTestCase {
995
996
expected: """
996
997
import veryveryverylongmodulenameherebecauseitistypical // special sentinel comment
997
998
999
+ let x // this comment should line up with 45
998
1000
func fooBarBazRunningOutOfIdeas() { // comment that needs to move
999
1001
if foo { // comment is fine
1000
1002
}
You can’t perform that action at this time.
0 commit comments