Fix inline display ordering: deleted lines appeared before unrelated additions#960
Open
ruudk wants to merge 2 commits intoWilfred:masterfrom
Open
Fix inline display ordering: deleted lines appeared before unrelated additions#960ruudk wants to merge 2 commits intoWilfred:masterfrom
ruudk wants to merge 2 commits intoWilfred:masterfrom
Conversation
…additions
Given this diff between two PHP files:
```diff
namespace App\Service;
+use App\Model\Recipient;
use App\Context\ServiceContext;
interface Handler
{
+ /**
+ * @param list<int|Recipient> $recipients
+ */
public function handle(
ServiceContext $context,
- int ...$ids,
+ array $recipients,
) : void;
}
```
The inline display mode rendered the deleted line too early, before
the added use import and docblock:
```
5 namespace App\Service;
13 int ...$ids, <- deleted, shown too early
7 use App\Model\Recipient;
12 /**
13 * @param ...
14 */
17 array $recipients, <- replacement, far below
```
After this fix, deletions appear adjacent to their replacements:
```
5 namespace App\Service;
7 use App\Model\Recipient;
12 /**
13 * @param ...
14 */
13 int ...$ids, <- now right before replacement
17 array $recipients,
```
The root cause was that the inline display iterated hunk lines in two
separate passes: first all old (deleted) lines, then all new (added)
lines. The fix merges these into a single loop that processes both
sides of each matched pair together.
Author
|
@Wilfred This one is ready whenever you are :) Thanks for making diffs fantastic 😍 |
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.
Bump tree-sitter-php from 0.23.11 to 0.24.2
Fix inline display ordering: deleted lines appeared before unrelated additions
Given this diff between two PHP files:
The inline display mode rendered the deleted line too early, before
the added use import and docblock:
After this fix, deletions appear adjacent to their replacements:
The root cause was that the inline display iterated hunk lines in two
separate passes: first all old (deleted) lines, then all new (added)
lines. The fix merges these into a single loop that processes both
sides of each matched pair together.