nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.9k stars 639 forks source link

`blockComments` rule will comment out valid method line if document comment have blank line. #1114

Closed r-plus closed 2 years ago

r-plus commented 2 years ago

When document comment have blank line, blockComments rule will comment out method defined line.

before format

/**
  foo

  bar
*/
func foo() {}

after format

/// foo
///
/// bar
///func foo() {}

SwiftFormat version: 0.49.1 macOS 11.6

meherkasam commented 2 years ago

I am also able to reproduce this issue for a function call.

Sample code:

/**
 Some comment.

 Some explanation.
 */
SomeFunc(
    SomeParam
)

Command run:

swiftformat test.swift --rules blockComments

Expected output:

/// Some comment.
///
/// Some explanation.
SomeFunc(
    SomeParam
)

Actual output:

/// Some comment.
///
/// Some explanation.
///SomeFunc(
    SomeParam
)
nicklockwood commented 2 years ago

Thanks for reporting - I'll get it fixed asap.

nicklockwood commented 2 years ago

@r-plus @meherkasam fixed in 0.49.2

meherkasam commented 2 years ago

Thanks for fixing this, @nicklockwood. Unfortunately, I'm still able to reproduce this issue for a comment in a slightly different format. Here's a simplified example:

/**
 Line 1.

 Line 2.

 Line 3.
 */
SomeFunc(someParam)

Command to run:

swiftformat test.swift --rules blockComments

Expected:

/// Line 1.
///
/// Line 2.
///
/// Line 3.
SomeFunc(someParam)

Actual:

/// Line 1.
///
/// Line 2.
///
/// Line 3.
///SomeFunc(someParam)
nicklockwood commented 2 years ago

@meherkasam d'oh! OK, I'll try again.

nicklockwood commented 2 years ago

@meherkasam fixed in 0.49.3