swiftlang / swift-format

Formatting technology for Swift source code
Apache License 2.0
2.55k stars 231 forks source link

swift-format Incorrectly duplicates comments to subsequent lines #843

Open gvozdvmozgu opened 1 month ago

gvozdvmozgu commented 1 month ago

When formatting Swift code using swift-format, comments from one line are improperly duplicated to the following lines.

Steps to Reproduce:

  1. Create a Swift file (test.swift) with the following content:

    1 // test
    +1
  2. Run the following command to format the code:

    swift run swift-format test.swift
  3. Check the contents of test.swift after formatting:

    1  // test
    +1  // test
ahoppen commented 1 month ago

Synced to Apple’s issue tracker as rdar://137698840