Option to show invisible characters
Tabs and spaces are the most important IMO. Carriage returns and line feeds are lower priority, especially since edit already shows the line ending style.
This is a feature that I enable on every editor when possible, so that I can easily visually check:
- Are there trailing spaces?
- Am I using the right indentation style? Is there mixed indentation?
- Are there mixed line endings?
I'm not sure what a good shortcut would be, but this feature would probably go under the "View" menu.
Spaces are often represented as ·, and tabs are often represented with an arrow character like →.
Yep, I also use that a lot. I think this would be really helpful.
Regarding the middle dot "·", we can't easily use that due to the legacy console on Windows. The East Asian Width property of that character is ambiguous, and you can see over in #115 what that results in. 😢
Initially, until we have settings, the invisible characters should only show up within the current text selection though. That represents a good trade-off IMO between people who like and who dislike this feature.
The relevant code is around here: https://github.com/microsoft/edit/blob/f88609160afa8a6d19a5bcccaf1870b0c6b78e41/src/buffer/mod.rs#L1653-L1701
Regarding the middle dot "·", we can't easily use that due to the legacy console on Windows. The East Asian Width property of that character is ambiguous, and you can see over in #115 what that results in. 😢
Oh, thanks for pointing that out. TBH I'd be happy with literally any character if you have any suggestions.
And I'm assuming that it should be a low contrast color so that the invisible characters don't grab attention. Heads up that this can be really annoying when light terminal themes get involved, due to the fact that some popular ones swap black and white and others don't.
Since the characters would only show up in selections initially, this is thankfully not a big deal, as the color of that is known. We can then use the existing contrasted() helper function to get a color with sufficient contrast for any terminal theme.
FWIW, as a replacement for "·" we can use "∙". I kid you not, that's a different character. Depending on your OS the two may look completely identical. They're these two:
- https://codepoints.net/U+00B7
- https://codepoints.net/U+2219
We already use the latter for drawing the word-wrap indicators in the left margin.