nicklockwood / SwiftFormat

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

`wrapSingleLineComments` applies to multiline comments as well #1270

Closed awein closed 2 years ago

awein commented 2 years ago

The new wrapSingleLineComments rule introduced with #1151 is transforming this comment

    /// See [Visual Format Language](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html)
    /// in Apple's documentation.

into

    /// See [Visual Format
    // Language](https://developer.apple.com/library/archive/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html)
    /// in Apple's documentation.
choulepoka commented 2 years ago

And here is another side-effect:

loadPreviousSubject
            .removeDuplicates() // Little trick, when prefetching, the requested row index is sent, and if we receive 2-times the same index, we know we can discard the 2nd invocation, because we just loaded it

Became:

loadPreviousSubject
            .removeDuplicates() // Little trick, when prefetching, the requested row index is sent, and if we receive 2-times the same index, we know we can discard the 2nd invocation, because we just
            .removeDuplicates() // loaded it

For now, I will disable the rule itself, because it's not ready

pronebird commented 2 years ago

The other issue with this that it ignores triple slash /// and breaks with //

Screenshot 2022-09-29 at 13 26 05
nicklockwood commented 2 years ago

Thanks all, I'll get these issues fixed asap

nicklockwood commented 2 years ago

@pronebird @choulepoka I've fixed your issues in 0.50.1

@awein I don't have a solution for this case yet. The best option is probably to disable the wrapSingleLineComments rule for now.

orchetect commented 2 years ago

Great new feature with the comment wrapping - love it.

Just tagging on here along with @awein's issue, but a variation on the edge case.

Using SwiftFormat 0.50.2 default settings except maxwidth=100 and swiftversion=5.5.

/// See [Link](https://www.domain.com/pathextension/pathextension/pathextension/pathextension/pathextension/pathextension).

Each time swiftformat is run, it inserts a blank comment line after "See".

One iteration:

/// See
///
///[Link](https://www.domain.com/pathextension/pathextension/pathextension/pathextension/pathextension/pathextension).

Two iterations:

/// See
///
///
///[Link](https://www.domain.com/pathextension/pathextension/pathextension/pathextension/pathextension/pathextension).

etc.

nicklockwood commented 2 years ago

@awein @orchetect fixed in 0.50.3