Repository navigation
Fixes innaccurate, noisy diffs - #235
Conversation
- replaces character-level approach `codemirror/merge` was using which produced noisy, largely useless highlights - 2 pass strategy: diffLines first, and then diffWordsWithSpace for inline stuff
- separation of concerns; core logic should not be in web...
📝 WalkthroughWalkthroughThis PR extracts diff mark computation logic from the CellContent component into a reusable utility module ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/core/src/diffMarks.ts`:
- Around line 51-106: computeDiffMarks is too complex; extract smaller helper
functions to reduce cognitive complexity: move the line-marking logic into a
helper like markHunkLines(lineOfPos, hunkStart, hunkEnd, lineClasses), move
class selection into chooseClasses(side, diffMode, isWhitespaceOnly) that
returns {lineClass, inlineClass}, move inline range construction into
buildInlineRangesForHunk({pendingRemoved, hunkValue, hunkStart, inlineClass})
which returns inlineRanges to append, and move bOffset/pendingRemoved
orchestration into the top-level computeDiffMarks that simply iterates hunks and
calls markHunkLines, chooseClasses, and buildInlineRangesForHunk (also add a
small helper advanceOffset(bOffset, hunk) if helpful); ensure exported behavior
and symbols computeDiffMarks, diffWordsWithSpace usage, and
SIDE_CLASSES/CONFLICT_CLASSES semantics remain unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: a4fcd4b3-302e-4857-b9a9-770b3802db3b
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
package.jsonpackages/core/src/diffMarks.tspackages/core/src/index.tspackages/web/client/src/components/CellContent.tsx



Before:
After:
Motivation:
Previously, we were (a) diffing twice, (b) producing character-level, instead of word-level diffs. This uses the standard
diffpackage for a 2-pass line, then word, level diff.Side-benefits:
packages/coreinstead ofpackages/web