Skip to content

Commit 075c83e

Browse files
committed
Fix newline detection logic for carriage return line feeds
`\r\n` is considered a single character in Unicode and we thus need to check for it specifically and checking for `\n` on its own is not sufficient.
1 parent 2980946 commit 075c83e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/SwiftParserDiagnostics/MultiLineStringLiteralDiagnosticsGenerator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ final class MultiLineStringLiteralIndentationDiagnosticsGenerator: SyntaxVisitor
131131
}
132132
switch previousToken.tokenKind {
133133
case .stringSegment(let stringSegment):
134-
return stringSegment.hasSuffix("\r") || stringSegment.hasSuffix("\n")
134+
return stringSegment.last?.isNewline ?? false
135135
default:
136136
// FIXME: newlines should never be part of trailing trivia
137137
return previousToken.trailingTrivia.contains(where: { $0.isNewline })

0 commit comments

Comments
 (0)