Underline the changed parts of a renamed path - #1042
Open
VXNCXNX wants to merge 1 commit into
Open
Conversation
a rename between long paths made the reader diff the two strings by eye. Underline the path segments that actually differ. Plain output is unchanged when colour is off. Written with AI assistance (Claude Code); I have read the change and am accountable for it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #963.
Disclosure per AI_POLICY.md: written with AI assistance (Claude Code). I've read every line and am accountable for it; happy to discuss any part.
You asked to underline the changed parts of the path in a rename header. This does that, segment by segment on
/:(brackets = underlined). The last one is the case from your issue: the left side is entirely unchanged, so only the added
srcis marked.The one design question
extra_infois a plainString, so underlining meant either embedding codes or changing the type. I kept theStringand embedded, gated on the already-computeduse_color. Changing the type would have rippled throughsummary.rs,main.rs(~10 sites),inline.rs,side_by_side.rsandstyle.rs— far more than this issue warrants. As done, exactly one call site changed.One subtlety worth flagging:
style.rs:569dims the whole line, so the underline is closed with\x1b[24m(underline-off) rather than\x1b[0m, which would have killed the dim for the rest of the line. That's also why owo-colors'Stylewasn't usable here — it emits a full reset.--color neverreturns the plain strings untouched, verified withcat -vfor all four shapes and pinned by a test.Tests cover the four shapes above plus the no-colour case.