Skip to content

Conversation

@Saga4
Copy link

@Saga4 Saga4 commented Mar 22, 2025

closes #505
Desc:
🔍 Problem
The existing implementation of parseAllHunks was incorrectly calculating line ranges when processing certain GNU diff formats. This caused issues with:

  • Inaccurate line number reporting in hunks
  • Missing context within modified ranges
  • Incorrect handling of adjacent changes

💡 Solution
This PR rewrites the parseAllHunks function to use a more robust multi-pass approach:

  • First identifies the exact modified line range by using actual line numbers from the diff data
  • Collects both added lines and normal lines within the modified range
  • Reconstructs the changed/added content with proper line ordering
  • Explicitly handles edge cases like "No newline at end of file" markers

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@Saga4 Saga4 requested review from a team as code owners March 22, 2025 20:55
@google-cla
Copy link

google-cla bot commented Mar 22, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Mar 22, 2025
@Saga4 Saga4 mentioned this pull request Mar 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect code suggestion

2 participants