Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unclear which part of long lines is being pointed to #327

Open
ysthakur opened this issue Dec 26, 2023 · 1 comment
Open

Unclear which part of long lines is being pointed to #327

ysthakur opened this issue Dec 26, 2023 · 1 comment

Comments

@ysthakur
Copy link

With long lines that are wrapped, it's unclear which part of the line is being pointed to.

Here's a screenshot, as an example:

image

And as text:

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 in between to make it span multiple lines aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "-h" {
   ·         ──┬─                                                                                                                                                                   ──┬─
   ·           │                                                                                                                                                                      ╰── duplicate flag
   ·           ╰── already given here
 4 │             desc "foo bar baz"
   ╰────

As you can see, when my terminal wraps that long line, it can be hard to tell where exactly the span is pointing. Is there a way to underline or highlight the text covered by those spans? I checked out GraphicalTheme, but that doesn't seem to have a way to configure this. I guess I could write my own ReportHandler based off of miette's, but that would take effort.

If such a feature doesn't exist in miette but the maintainers are fine with adding it, I could try implementing it. Apologies if someone's asked about this already, but I couldn't find any issues.

@Benjamin-L
Copy link
Contributor

#20 is possibly related. My understanding of the idea with #20 is that we could trim snippets horizontally similar to the way we're currently trimming them vertically (by only rendering a few context lines around the span).

In your example, I'm imagining that might look something like this:

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"
   ╰────

I think having an option in GraphicalTheme to highlight spans by swapping the fg/bg colors or with ansi underlines would be useful, even if the issues with long lines are solved another way. There was a great blog post I saw a while ago that recommended fg/bg swap as the default way to format compiler errors because it has a better shot at handling things like bidi text or misprediction of character display widths. I don't fully agree that it should be the default, but think it would be a good to support as an option. Unfortunately, I couldn't find the original post :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants