fix: use diff line index as 1-based line numbers#389
Conversation
After doing some experiments, I found that the `Diff` API (from `gix-imara-diff` crate) uses 0-based line indexes instead of 1-based line numbers. Furthermore the `UnifiedDiff` API (again from `gix-imara-diff` crate) uses 1-based line numbers when printing hunk headers (`@@ -3, 5 +3,6 @@`). Thus, printing the unified diff into a patch file remains the same as it was already accurate. So this patch gracefully increments the line indexes by 1 so they can be compared to ranges of 1-based line numbers. I left the `print_diff()` function in the test module as helper/proof when analyzing future regressions.
|
Warning Review limit reached
More reviews will be available in 42 minutes and 55 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR updates diff-to-line-range conversion to use 1-based inclusive bounds, adjusts overlap and pure-removal handling to match, and changes test and debug output to reflect the updated line numbering. ChangesDiff range handling and output
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #389 +/- ##
==========================================
+ Coverage 92.26% 92.38% +0.12%
==========================================
Files 23 23
Lines 3750 3796 +46
==========================================
+ Hits 3460 3507 +47
+ Misses 290 289 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
After doing some experiments, I found that the
gix_imara_diff::DiffAPI uses 0-based line indexes instead of 1-based line numbers. Furthermore thegix_imara_diff::UnifiedDiffAPI uses 1-based line numbers when printing hunk headers (@@ -3,5 +3,6 @@). Thus, printing the unified diff into a patch file remains the same as it was already accurate.So this patch increments the line indexes by 1 when they are be compared/normalized to ranges of 1-based line numbers.
I left the
print_diff()function in the test module as a helper/proof when analyzing future regressions.Summary by CodeRabbit