Skip to content

fix(site): enable word-level inline diff highlighting in DiffViewer#23423

Merged
DanielleMaywood merged 1 commit intomainfrom
dm/diff-viewer-word-level-highlighting
Mar 23, 2026
Merged

fix(site): enable word-level inline diff highlighting in DiffViewer#23423
DanielleMaywood merged 1 commit intomainfrom
dm/diff-viewer-word-level-highlighting

Conversation

@DanielleMaywood
Copy link
Copy Markdown
Contributor

🤖 This PR was written by Coder Agent on behalf of Danielle Maywood 🤖

Problem

Changed lines in the DiffViewer only had a full-line background tint with no indication of which specific words changed. This made it difficult to spot the actual modifications within a line, especially on lines with small edits.

Solution

Enable the lineDiffType: "word" option from @pierre/diffs in getDiffViewerOptions. This adds a darker highlight on the specific changed words within addition/deletion lines, on top of the existing line-level background — matching the behavior users expect from GitHub's diff view.

This applies everywhere getDiffViewerOptions is used: the main DiffViewer, plus the Tool, WriteFileTool, and EditFilesTool components.

@github-actions github-actions Bot added the community Pull Requests and issues created by the community. label Mar 23, 2026
The diffViewerCSS override was applying
`background-color: transparent !important` to all `[data-line]`
elements (except selected lines). This killed the library's colored
backgrounds on change-addition and change-deletion lines, hiding
both the line-level tint and the word-level emphasis highlights
that @pierre/diffs computes by default.

Narrow the transparent override to exclude `[data-line-type='change-addition']`
and `[data-line-type='change-deletion']` so the library's built-in
addition/deletion backgrounds and inline word-diff emphasis are
preserved — matching the highlighting behavior users expect from
GitHub's diff view.
@DanielleMaywood DanielleMaywood force-pushed the dm/diff-viewer-word-level-highlighting branch from 0057ca6 to 32ec7d5 Compare March 23, 2026 09:46
@DanielleMaywood DanielleMaywood marked this pull request as ready for review March 23, 2026 10:23
@DanielleMaywood DanielleMaywood merged commit eca2257 into main Mar 23, 2026
32 checks passed
@DanielleMaywood DanielleMaywood deleted the dm/diff-viewer-word-level-highlighting branch March 23, 2026 10:30
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

community Pull Requests and issues created by the community.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants