Repository navigation
Put word highlights on the words that changed - #30
Merged
Merged
Conversation
word_diff_ranges rebuilt each word's offset from str.split() as if every word started at 0 and was followed by exactly one space. Leading indentation and runs of spaces were dropped, so on any indented line the marks landed left of the changed words, often inside the indentation. The ranges now come from the real span of each word in the line. Bump version to 0.11.3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ
The end-to-end test looked for a bare <mark>old</mark>. Matching on ">old</mark>" still proves the mark starts on the changed word, and keeps passing if the mark gains a class, as dgsienko#31 does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ
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.
Problem
On any indented line, the word-level highlights land to the left of the words that changed, often starting inside the indentation. Every changed line in a typical C#, Python or JS file is affected.
word_diff_rangesrebuilt each word's offset fromstr.split(), as if the first word started at column 0 and every word was followed by exactly one space. Leading indentation, tabs and runs of spaces were dropped from the count, so with 8 spaces of indentation every mark was shifted 8 characters left.Fix
_word_spanstakes each word's real span withre.finditer(r"\S+"), and the ranges are built from those spans. The matching itself (SequenceMatcherover the words) is unchanged.Tests
test_word_diff_ranges: new cases for leading spaces, a leading tab, runs of spaces between words, and a deleted run of words.test_highlight.py: an end-to-end check thatparse_diff_to_jsonwraps exactly the changed word of an indented line in<mark>.The new cases fail on
mainand pass with the fix.pytest(322 passed),ruff checkandruff format --checkare clean.Version bumped to 0.11.3.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Xshwvphn2wQmVKLLS2G9kJ