Skip to content

Special way to underline with empty spans #108

Open

Description

@epage

The toml crate occasionally returns empty spans and #107 fixed it so we could render something but it might be useful to try to highlight the space between characters, rather than a character.

Activity

  1. chengr4 commented on Aug 14, 2024

    @chengr4

    Hi @epage,

    I’m working on addressing this ticket and would appreciate your guidance.

    Background

    According to your fix in #107, you added additional col annotation span allowing symbols of Error (^), Warning (-) etc., to be displayed.


    My understanding of the goal for this ticket is illustrated by the following example:

    asdf_
    
    as_f
           'd" belongs here        

    '_' represents "highlight" rather than any specific symbol.

    If this is the case, we would need to find a way to place the "highlight" either directly after or between characters, which is very different (I think) from the current implementation. Do you have any ideas on how we might achieve this? Or is my understanding for ticket incorrect?

  2. epage commented on Aug 14, 2024

    @epage
    ContributorAuthor

    To recap, toml sometimes highlights empty ranges (e.g. bytes at 0..0), like at EOF or EOL when a terminating character is needed.

    Do you have any ideas on how we might achieve this? Or is my understanding for ticket incorrect?

    This is a "needs design" type of issue; no decision is made about what this should look like.

    One idea I've toyed with for EOL is for us to render \n or \r\n as Dimmed and highlight those. We could pick a character to similarly represent EOF. In snapbox diffs, I chose ∅.

    That is only one idea and that doesn't cover other cases of empty spans.

    @estebank any thoughts?

  3. estebank commented on Aug 15, 2024

    @estebank

    One option is to do what we do in rustc now: replace the ASCII control characters with their Unicode graphical representation (like ␍). For zero-width spans in rustc in general, we print a one-width underline starting at the right position and "bleeding" to the right. If you look at a representative test, you can see that showing something seems to work better than leaving the "hidden" char hidden. I had considered a long time ago using /\ as an underline pointing in between to char positions, but ended up never doing it because there was no way of doing the same for the secondary spans (-).

  4. chengr4 commented on Aug 15, 2024

    @chengr4

    If I understand correctly, now
    For EOL, we have two options

    # render \n or \r\n
    This is a line of "code␍␊
                           ^
    # OR
    
    # print a one-width underline
    This is a line of "code_
                           ^

    And for EOF, we also have two options

    # render ∅
    This is a line of "code∅
                          ^
    # OR
    
    # print a one-width underline
    This is a line of "code_
                           ^
  5. estebank commented on Aug 19, 2024

    @estebank

    @chengr4 you can also have, for both of these:

    This is a line of "code
                           ^
    
  6. chengr4 commented on Aug 20, 2024

    @chengr4

    @chengr4 you can also have, for both of these:

    This is a line of "code
                           ^
    

    @estebank I think this is the current state and @epage wants to change it.

    Or I misunderstood 🤔?

  7. estebank commented on Aug 20, 2024

    @estebank

    Right, what I'm saying is that leaving as-is is a valid decision (although not necessarily ideal). I've found pointing at nothing also useful for suggestions like

    code
        ^ help: missing `;` here
    

    so you might need the flexibility to support both substitutions and the current behavior, depending on whether you want to point at a hidden char or merely point at the point after some code (which can be right on a newline).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions