tamer: diagnose::report: Restore source line preview for invalid UTF-8
This was removed in a previous commit while working on simplifying the implementation, with the hope of returning to it once things were in a better place. They are, so let's bring it back. DEV-12151main
parent
f8dda12fae
commit
2ae6df38e7
|
@ -386,6 +386,11 @@ where
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
|
body.extend(vec![
|
||||||
|
SectionLine::SourceLinePadding,
|
||||||
|
SectionLine::SourceLine(srcline.into()),
|
||||||
|
SectionLine::SourceLinePadding,
|
||||||
|
]);
|
||||||
body.extend(
|
body.extend(
|
||||||
label.map(|l| SectionLine::Footnote(level, l)),
|
label.map(|l| SectionLine::Footnote(level, l)),
|
||||||
);
|
);
|
||||||
|
|
|
@ -453,6 +453,7 @@ fn fallback_when_column_fails_to_resolve() {
|
||||||
let ctx = Context::from("invalid/utf8");
|
let ctx = Context::from("invalid/utf8");
|
||||||
|
|
||||||
let span = ctx.span(4, 2);
|
let span = ctx.span(4, 2);
|
||||||
|
let lossy = String::from_utf8_lossy(FILE_INVALID_UTF8);
|
||||||
|
|
||||||
assert_report!(
|
assert_report!(
|
||||||
"column resolution failure",
|
"column resolution failure",
|
||||||
|
@ -460,6 +461,9 @@ fn fallback_when_column_fails_to_resolve() {
|
||||||
format!("\
|
format!("\
|
||||||
error: column resolution failure
|
error: column resolution failure
|
||||||
--> invalid/utf8:1 bytes 4--6
|
--> invalid/utf8:1 bytes 4--6
|
||||||
|
|
|
||||||
|
1 | {lossy}
|
||||||
|
|
|
||||||
= error: an error we do not want to suppress
|
= error: an error we do not want to suppress
|
||||||
= help: unable to calculate columns because the line is not a valid UTF-8 string
|
= help: unable to calculate columns because the line is not a valid UTF-8 string
|
||||||
= help: you have been provided with 0-indexed line-relative inclusive byte offsets
|
= help: you have been provided with 0-indexed line-relative inclusive byte offsets
|
||||||
|
|
Loading…
Reference in New Issue