Fix splitLineCount and unifiedLineCount on hunks#241
Merged
Conversation
It wasn't being computed from before.
amadeus
commented
Dec 18, 2025
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes incorrect calculations for splitLineCount and unifiedLineCount on diff hunks. The previous implementation incorrectly calculated these values as simple max/count of additions and deletions without accounting for context lines. The fix properly computes these counts by iterating through hunk content and summing context lines with the appropriate calculation for change blocks.
- Updated the calculation logic to properly account for context lines in both split and unified modes
- Added comprehensive tests that verify the calculated counts match actual rendered output
- Updated all affected snapshots to reflect the corrected values
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/diffs/src/utils/parsePatchFiles.ts | Replaced simple max/count calculations with proper reduce logic that accounts for context lines in both splitLineCount and unifiedLineCount |
| packages/diffs/test/testUtils.ts | Updated verification logic to match new calculation method and added helper functions to count rendered lines and split rows |
| packages/diffs/test/parsePatchFiles.test.ts | Added two new tests that verify calculated counts match actual rendered output in both split and unified modes |
| packages/diffs/test/snapshots/*.snap | Updated snapshot values to reflect corrected splitLineCount and unifiedLineCount calculations across all test files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* Lets be sure we are getting proper numbers out of `data-line-index` * Why allocate massive array when 1 smol array do trick
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
A classic case of -- we didn't really depend on this so never totally realized it was wrong. Anyways, these values were wrong and it started showing up in my virtualization work because I depended on them.
Also added tests to make sure I don't fuck these up again