Make the word highlighting colors follow the hunk rather than the line#2400
Conversation
|
For For Maybe hovering that text could show a tooltip explaining this? Like, "this word was recently added on |
|
A tooltip could work, but requires the user to hover which I think is less than ideal. Maybe we shouldn't be using green for word added to the removal, but using an intermediate color like orange? It's an intermediate color that doesn't have the meaning of green but is still distinctive. |
Yeah that was just meant as a way for the user to discover the meaning of the color. Adding it to the legend at the top could also work. I like the orange! I wonder if |
|
That darker orange does get quite close to the red though. I guess we'll see in practice whether that is a problem. |
|
What if you used the original lighter orange but had the text be black (in the first image it's white)? Wouldn't that uphold a good contrast ratio? Or would that look awful in some way? |
|
How does it look next to a |
I strongly prefer all of those over the currently implemented one. Among the alternatives with black text, I have a mild preference for the 3rd variant (strong orange). |
|
Sure, works for me. Changed it. |









While looking at one of the example from #2394, I found my-self a bit perplex at the word highlighting we do.
In particular regarding the color we use which currently follows the color of the line, but that doesn't really make sense, as we want to show what was removed/added between the two part of the hunk, and for that red/green are the standard colors.
This PR therefor changes the word highlighting to always show removed words in red, and added words in green (EDIT: except in a removed line where we use orange, see below). An attempt is made to dim the color for a removed line, where knowing exactly what changed is less relevant.
Light theme:
V1 & V2
Dark theme:
V1 & V2
First commit is the actual change, second commit is a refactor/simplification and the other are the orange change.
Testing: http://localhost:8000/gh-range-diff/rust-lang/miri/98cb1d3d48fa7c8e97994050bfd69e8f3da2a1a7..3f8007e19b8cac3d08fb07579bde3217c58807e4/e0b3afbdd5362aa348abc6661ed6417d1a21f58c..d811aaf958594156e2ce38365b835c361aa88de9
@RalfJung does the new colors make sense to you?