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 {
6767
6868    switch kind {
6969    case .line, .docLine:
70+       self.length = text.count
7071      self.text = [text]
7172      self.text[0].removeFirst(kind.prefixLength)
72-       self.length = self.text.reduce(0, { $0 + $1.count + kind.prefixLength + 1 })
7373
7474    case .block, .docBlock:
7575      var fulltext: String = text
Original file line number Diff line number Diff line change @@ -558,7 +558,9 @@ public class PrettyPrinter {
558558  /// Indicates whether the current line can fit a string of the given length. If no length
559559  /// is given, it indicates whether the current line can accomodate *any* text.
560560  private  func  canFit( _ length:  Int  =  1 )  ->  Bool  { 
561+ //    print("\(length)")
561562    let  spaceRemaining  =  configuration. lineLength -  outputBuffer. column
563+ //    print("let \(spaceRemaining) = \(configuration.lineLength) - \(outputBuffer.column)")
562564    return  outputBuffer. isAtStartOfLine || length <=  spaceRemaining
563565  } 
564566
Original file line number Diff line number Diff line change @@ -985,7 +985,8 @@ final class CommentTests: PrettyPrintTestCase {
985985    assertPrettyPrintEqual ( 
986986      input:  """ 
987987        import veryveryverylongmodulenameherebecauseitistypical  // special sentinel comment 
988- 
988+          
989+         let x  // this comment should line up with 45 
989990        func fooBarBazRunningOutOfIdeas() {  1️⃣// comment that needs to move 
990991          if foo {  // comment is fine 
991992          } 
@@ -995,6 +996,7 @@ final class CommentTests: PrettyPrintTestCase {
995996      expected:  """ 
996997        import veryveryverylongmodulenameherebecauseitistypical  // special sentinel comment 
997998
999+         let x  // this comment should line up with 45 
9981000        func fooBarBazRunningOutOfIdeas() {  // comment that needs to move 
9991001          if foo {  // comment is fine 
10001002          } 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments