You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Miette currently renders labels covering an empty span with an arrow character (▲), while labels covering a nonempty span are rendered with an underline. This is useful, since it would otherwise be impossible to distinguish between an empty label pointing to the left of a character from labels covering that character.
The issue is that, after #202, a span covering a nonempty byte range doesn't necessarily mean that it covers a nonzero number of visible columns in the output. IMO, when a span is pointing at a zero-width character, it should use the ▲ pointer rather than ┬. In the example below, the expected output is clear that it's pointing to something inside the parentheses, while the current output looks like it's pointing to the ) character itself.
#[test]fnsingle_line_highlight_with_zero_width_space() -> Result<(),MietteError>{#[derive(Debug,Diagnostic,Error)]#[error("oops!")]#[diagnostic(code(oops::my::bad), help("try doing it better next time?"))]structMyBad{#[source_code]src:NamedSource,#[label("this bit here")]highlight:SourceSpan,}let src = "ZWSP inside this: (\u{200B})\n".to_string();let err = MyBad{src:NamedSource::new("bad_file.rs", src),highlight:(19,3).into(),};let out = fmt_report(err.into());println!("Error: {}", out);// There's a literal ZWSP inside the parens for this string, because raw// strings don't support escapes.//// It may or may not show up in your editor :)let expected = r#"oops::my::bad × oops! ╭─[bad_file.rs:1:1] 1 │ ZWSP inside this: () · ▲ · ╰── this bit here ╰──── help: try doing it better next time?"#.trim_start().to_string();assert_eq!(expected, out);Ok(())}
Expected output
× oops!
╭─[bad_file.rs:1:1]
1 │ ZWSP inside this: ()
· ▲
· ╰── this bit here
╰────
help: try doing it better next time?
Current output
× oops!
╭─[bad_file.rs:1:1]
1 │ ZWSP inside this: ()
· ┬
· ╰── this bit here
╰────
help: try doing it better next time?
The text was updated successfully, but these errors were encountered:
In #221, @Boshen mentioned that they expected ▲ to be used when pointing at a 1-column span, not just a 0-column span. I would lean towards keeping ┬ for 1-column spans, but I think the right answer here isn't entirely clear.
I prefer keeping ▲ the way it is now: its purpose is to say "actually, this is different, and does not cover any length of span", vs "this is the range that this covers, and it happens to be 1 in length"
Important to note that the current meaning isn't "this is the range that this covers, and it happens to be 1 in length" anymore. Since visible columns don't necessarily correspond to the byte range the span covers, it's "this span covers more than zero bytes, but may cover zero columns of the rendered output". In the ZWSP example earlier, the range that ┬ is rendered under doesn't correspond to the range the span actually covers, since the ) character is not included.
Miette currently renders labels covering an empty span with an arrow character (
▲
), while labels covering a nonempty span are rendered with an underline. This is useful, since it would otherwise be impossible to distinguish between an empty label pointing to the left of a character from labels covering that character.The issue is that, after #202, a span covering a nonempty byte range doesn't necessarily mean that it covers a nonzero number of visible columns in the output. IMO, when a span is pointing at a zero-width character, it should use the
▲
pointer rather than┬
. In the example below, the expected output is clear that it's pointing to something inside the parentheses, while the current output looks like it's pointing to the)
character itself.Steps to reproduce
Source:
ZWSP inside this: (\u{200B})\n
Span: (19,3)
Unit test
Expected output
Current output
The text was updated successfully, but these errors were encountered: