miette
miette copied to clipboard
MietteReporter: Render a "bounding box" when the lines are way too long
This is going to be hard, but it's going to make out-of-the-box display for, say, a bunch of single-line json, a lot easier.
Could you elaborate on how you envisioned this? Is this still something you want?
Would this only involve trimming snippets horizontally like they're currently trimmed vertically (like @Benjamin-L said here (sorry for the ping)) or would it involve wrapping long lines? (or both?)
It's trimming horizontally, finding a "display window".
For example, if you have 10,000 chars of JSON on a single line, and the syntax error is on char 5,000, then it would only render the syntax error range, plus a certain number of characters before and after, possibly with ellipses.
The case that came up in #327 is slightly trickier, but still probably covered by this issue. It's like a 10,000 char JSON file where there's one label at char 10 and one at char 90,000. There are two ways I can think of to display that: splitting it into two separate snippets or putting it in one snippet that's broken in the middle.
Error: gen_completions::deser::kdl::duplicate_flag (link)
× Error encountered while deserializing
╰─▶ Error encountered while reading command information
╭─[test.kdl:2:1]
2 │ flags {
3 │ ··· aaaaaaaaaaaaaa" "-h" {
· ──┬─
· ╰── duplicate flag
4 │ desc "foo bar baz"
╰────
╭─[test.kdl:2:1]
2 │ flags {
3 │ "-h" "--very long string ···
· ──┬─
· ╰── already given here
4 │ desc "foo bar baz"
╰────
versus
Error: gen_completions::deser::kdl::duplicate_flag (link)
× Error encountered while deserializing
╰─▶ Error encountered while reading command information
╭─[test.kdl:2:1]
2 │ flags {
3 │ "-h" "--very long string ··· aaaaaa" "-h" {
· ──┬─ ──┬─
· │ ╰── duplicate flag
· ╰── already given here
4 │ desc "foo bar baz"
╰────
The first option is likely easier to implement, and more consistent with how vertical trimming currently works.
splitting it into two definitely seems like the most readable alternative, yeh