miette icon indicating copy to clipboard operation
miette copied to clipboard

MietteReporter: Render a "bounding box" when the lines are way too long

Open zkat opened this issue 3 years ago • 5 comments

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.

zkat avatar Aug 18 '21 01:08 zkat

Could you elaborate on how you envisioned this? Is this still something you want?

jdonszelmann avatar Nov 10 '23 08:11 jdonszelmann

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?)

ysthakur avatar Jan 10 '24 22:01 ysthakur

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.

zkat avatar Jan 11 '24 00:01 zkat

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.

Benjamin-L avatar Jan 11 '24 02:01 Benjamin-L

splitting it into two definitely seems like the most readable alternative, yeh

zkat avatar Jan 11 '24 18:01 zkat