nicklockwood / SwiftFormat

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

Regression on empty lines in multiline strings not indented. #1700

Open rafaelpedretti-toast opened 1 month ago

rafaelpedretti-toast commented 1 month ago

It seems that issue #1382 is happening again on version 0.53.9

https://github.com/nicklockwood/SwiftFormat/assets/102023813/22972008-60c0-4b43-bbda-714db0fd026e

nicklockwood commented 1 month ago

@rafaelpedretti-toast I don't think this is the same issue. The bug before was that when using --trimwhitespace nonblank-lines the indent rule could cause multiline string literals not to compile due to inconsistently indented white space.

But if I understand the issue in your video, it's that SwiftFormat is trimming leading whitespace from a blank line in a multiline string literal, which is by design, and doesn't cause any compilation problems as far as I know?

If you want to preserve that space you can use --trimwhitespace nonblank-lines. If you want to be able to preserve leading whitespace only for blank lines inside string literals, can you open a feature request? (but also, why?)