nicklockwood / SwiftFormat

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

Inconsistent whitespace in multi-line string literal with no multi-line string literal #1487

Closed g0ddest closed 1 year ago

g0ddest commented 1 year ago

Given file with the content:

func test() {
}

Result: error: Inconsistent whitespace in multi-line string literal at 2:2 in ...

swiftformat --version
0.51.13
nicklockwood commented 1 year ago

@g0ddest I think I've found the problem. It looks like you may have a vertical tab (U+000B) or form feed (U+000C) character in your file instead of a regular linebreak character. I thought these were illegal in Swift, so SwiftFormat doesn't check for them and it confuses the parser.

I'll get this fixed, but in the meantime if you replace that character it should solve the issue.

g0ddest commented 1 year ago

@nicklockwood thank you! I checked the code and there really is form feed 0xC symbol. It's weird one and I suppose swiftformat should warn you about these ones as check (but not like multi-line string).

nicklockwood commented 1 year ago

@g0ddest fixed in 0.51.14

nicklockwood commented 1 year ago

@g0ddest due to a merge screwup on my part, the fix was not actually included in 0.51.14. It's included in 0.51.15 instead.