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
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.
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?
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.
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 (-).
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).
Activity
chengr4 commentedon Aug 14, 2024
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
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?
epage commentedon Aug 14, 2024
To recap,
toml
sometimes highlights empty ranges (e.g. bytes at0..0
), like at EOF or EOL when a terminating character is needed.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. Insnapbox
diffs, I chose ∅.That is only one idea and that doesn't cover other cases of empty spans.
@estebank any thoughts?
estebank commentedon Aug 15, 2024
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 inrustc
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 (-
).chengr4 commentedon Aug 15, 2024
If I understand correctly, now
For EOL, we have two options
And for EOF, we also have two options
estebank commentedon Aug 19, 2024
@chengr4 you can also have, for both of these:
chengr4 commentedon Aug 20, 2024
@estebank I think this is the current state and @epage wants to change it.
Or I misunderstood 🤔?
estebank commentedon Aug 20, 2024
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
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).