Skip to content

Underline the changed parts of a renamed path - #1042

Open
VXNCXNX wants to merge 1 commit into
Wilfred:masterfrom
VXNCXNX:feat/underline-renamed-path-parts
Open

Underline the changed parts of a renamed path#1042
VXNCXNX wants to merge 1 commit into
Wilfred:masterfrom
VXNCXNX:feat/underline-renamed-path-parts

Conversation

@VXNCXNX

@VXNCXNX VXNCXNX commented Aug 14, 2026

Copy link
Copy Markdown

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 /:

same dir, new name    Renamed from src/[a.ts] to src/[b.ts]
same name, new dir    Renamed from [old]/a.ts to [new]/a.ts
both changed          Renamed from [old]/[a.ts] to [new]/[b.ts]
extra segment         Renamed from scripts/backup-db.ts to [src]/scripts/backup-db.ts

(brackets = underlined). The last one is the case from your issue: the left side is entirely unchanged, so only the added src is marked.

The one design question

extra_info is a plain String, so underlining meant either embedding codes or changing the type. I kept the String and embedded, gated on the already-computed use_color. Changing the type would have rippled through summary.rs, main.rs (~10 sites), inline.rs, side_by_side.rs and style.rs — far more than this issue warrants. As done, exactly one call site changed.

One subtlety worth flagging: style.rs:569 dims 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' Style wasn't usable here — it emits a full reset.

--color never returns the plain strings untouched, verified with cat -v for all four shapes and pinned by a test.

cargo test         124 passed (unit), 23 passed (integration)
cargo fmt --check  clean

Tests cover the four shapes above plus the no-colour case.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Highlight words changed when renaming files

1 participant