Decouple TextDiff engine and add reusable diff results#7
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughIntroduces a persistable Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Engine as TextDiffEngine
participant Result as TextDiffResult
participant View as TextDiffView / NSTextDiffView
participant Revert as RevertHandler
rect rgba(100, 150, 200, 0.5)
Note over User,Revert: Text-driven flow
User->>View: init(original, updated, mode)
View->>Engine: diff(original, updated, mode)
Engine->>Engine: compute segments
View->>View: render & enable revert
View->>Revert: revert actions enabled
end
rect rgba(200, 150, 100, 0.5)
Note over User,Revert: Result-driven flow
User->>Engine: result(original, updated, mode)
Engine->>Engine: compute segments, changes, summary
Engine->>Result: return TextDiffResult
User->>View: init(result)
View->>View: render from result
View->>Revert: revert actions disabled
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 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 `@Sources/TextDiff/DiffSegmentIndexer.swift`:
- Around line 33-44: The asserts around the textMatches validation are behind a
wrong compile guard (`#if` !TESTING) so they never run when TESTING is set; remove
the surrounding conditional or invert it so the asserts execute in debug/testing
builds. Specifically, in DiffSegmentIndexer.swift keep the textMatches calls and
the assert checks for originalMatches and updatedMatches (referencing
originalMatches, updatedMatches, textMatches, originalCursor, updatedCursor,
index, and segment.text) but delete the `#if` !TESTING / `#endif` wrapper (or change
it to `#if` TESTING) so the assertions run during testing/debugging.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b3159370-8e9e-4e3b-9d2c-e294a86a2c93
⛔ Files ignored due to path filters (1)
Tests/TextDiffTests/__Snapshots__/TextDiffSnapshotTests/precomputed_result_rendering.1.pngis excluded by!**/*.png
📒 Files selected for processing (14)
README.mdSources/TextDiff/AppKit/DiffRevertActionResolver.swiftSources/TextDiff/AppKit/DiffTextViewRepresentable.swiftSources/TextDiff/AppKit/NSTextDiffContentSource.swiftSources/TextDiff/AppKit/NSTextDiffView.swiftSources/TextDiff/DiffSegmentIndexer.swiftSources/TextDiff/TextDiffEngine.swiftSources/TextDiff/TextDiffResult.swiftSources/TextDiff/TextDiffView.swiftTests/TextDiffTests/DiffRevertActionResolverTests.swiftTests/TextDiffTests/NSTextDiffViewTests.swiftTests/TextDiffTests/SnapshotTestSupport.swiftTests/TextDiffTests/TextDiffEngineTests.swiftTests/TextDiffTests/TextDiffSnapshotTests.swift
Summary
TextDiffResultAPI with persistable change records and summary statsTextDiffViewandNSTextDiffViewTesting
swift test 2>&1 | xcsift --quietCloses #6
Summary by CodeRabbit
New Features
Documentation
Tests