Skip to content

Commit ab4848a

Browse files
committed
fix: CRLF newline handling and error span rendering
Previously, newline detection operated per character, causing CRLF to be treated as two separate newlines. This resulted in incorrect line numbers, extra blank lines, and misaligned error spans on Windows inputs. This change introduces CRLF-aware newline parsing while preserving support for LF, CR, and Unicode newline characters. Also fixes: - incorrect line/column calculation for multi-line spans - UTF-16 column alignment for multi-byte characters - off-by-one error in multiline underline rendering - zero-length spans not displaying a caret Error rendering is now consistent across platforms and input encodings. Merge after PR #257
1 parent ade9d7a commit ab4848a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/error.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ where
324324
}
325325

326326
impl<'tokens, 'src: 'tokens, I> LabelError<'tokens, I, DefaultExpected<'tokens, Token<'src>>>
327-
for RichError
327+
for RichError
328328
where
329329
I: ValueInput<'tokens, Token = Token<'src>, Span = Span>,
330330
{
@@ -704,8 +704,8 @@ let x: u32 = Left(
704704
let error = Error::CannotParse(
705705
"Expected value of type `u32`, got `Either<Either<_, u32>, _>`".to_string(),
706706
)
707-
.with_span(Span::new(41, FILE.len()))
708-
.with_file(Arc::from(FILE));
707+
.with_span(Span::new(41, FILE.len()))
708+
.with_file(Arc::from(FILE));
709709
let expected = r#"
710710
|
711711
2 | let x: u32 = Left(
@@ -885,4 +885,4 @@ let x: u32 = Left(
885885

886886
assert_eq!(&expected[1..], &error.to_string());
887887
}
888-
}
888+
}

0 commit comments

Comments
 (0)