Skip to content

Commit 0dd8527

Browse files
LeonMatthesLeonMatthesKDAB
authored andcommitted
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 6d5a5c7 commit 0dd8527

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
@@ -170,6 +170,14 @@ fn extract_expected_diags(source: &str) -> Vec<ExpectedDiagnostic> {
170170
}
171171
}
172172

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

0 commit comments

Comments
 (0)