Skip to content

Commit 8818370

Browse files
committed
Fix CRLF edge-case on Windows
If the end of a diagnostic falls on a newline CR of a CRLF, it should cover the entire CRLF, not just the CR.
1 parent c6af6dc commit 8818370

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

internal/compiler/tests/syntax_tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ fn extract_expected_diags(source: &str) -> Vec<ExpectedDiagnostic> {
168168
}
169169
}
170170

171+
// Windows edge-case, if the end falls on a newline, it should span the entire
172+
// newline character, which is two characters, not one.
173+
if let Some(end_offset) = end {
174+
if source.get(end_offset..=(end_offset + 1)) == Some("\r\n") {
175+
end = Some(end_offset + 1)
176+
};
177+
}
178+
171179
let expected_diag_level = match warning_or_error {
172180
"warning" => DiagnosticLevel::Warning,
173181
"error" => DiagnosticLevel::Error,

0 commit comments

Comments
 (0)