Skip to content

feat: add word-level intra-line diff highlighting - #15

Merged
jfyne merged 3 commits into
masterfrom
claude/explain-diff-rendering-6cyyG
Mar 30, 2026
Merged

feat: add word-level intra-line diff highlighting#15
jfyne merged 3 commits into
masterfrom
claude/explain-diff-rendering-6cyyG

Conversation

@jfyne

@jfyne jfyne commented Mar 30, 2026

Copy link
Copy Markdown
Owner

What's changed

Adds word-level intra-line diff highlighting for paired del/add lines using a Myers diff algorithm on word-boundary tokens, with a 70% threshold guard, CSS highlight styles, and a fix for template whitespace rendering in code-text divs.

Risk Profile

Signal Value Risk
Size 711 LOC (+700, -11) High
Files 7 files across 2 directories Medium
Sensitive paths None Normal
Test coverage 3 test files / 4 production files Moderate
Type Feature Normal

Overall: HIGH — size (711 LOC) sets floor to High; multiple medium signals (files, test coverage) would escalate but High is already the floor.

Suggested Review Order

# File What it does Link
1 worddiff.go Myers word-level diff algorithm: tokenizer, diff engine, and HTML renderer View
2 view.go Integrates intra-line diff into split and unified view builders View
3 styles.css CSS styles for .intra-del and .intra-add highlight spans View
4 template.html Fixes template whitespace in code-text divs using trim operators View
5 worddiff_test.go Unit tests for tokenizer, diff engine, rendering, and threshold logic View
6 view_diff_split_test.go Tests intra-line diff integration in split view (paired, unpaired, context) View
7 view_diff_test.go Tests intra-line diff integration in unified view (adjacent, non-adjacent) View

claude and others added 3 commits March 29, 2026 23:59
When a line is modified (del+add pair), highlight exactly which tokens
changed within the line instead of coloring the entire line. Uses a
Myers diff algorithm on word-boundary tokens with a 70% threshold guard
to skip noisy highlighting on completely rewritten lines.

https://claude.ai/code/session_01WegnnQtyhFJwahxoGF7C76
Template indentation was being rendered as visible content due to
white-space: pre-wrap. Use template trim operators to collapse
whitespace before and after template directives.

Fixes indentation display issue in diff views.
@jfyne
jfyne merged commit 3aee077 into master Mar 30, 2026
1 check passed
@jfyne
jfyne deleted the claude/explain-diff-rendering-6cyyG branch March 30, 2026 22:02
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.

2 participants