Skip to content

Fix inline display ordering: deleted lines appeared before unrelated additions#960

Open
ruudk wants to merge 2 commits intoWilfred:masterfrom
ruudk:bump-php
Open

Fix inline display ordering: deleted lines appeared before unrelated additions#960
ruudk wants to merge 2 commits intoWilfred:masterfrom
ruudk:bump-php

Conversation

@ruudk
Copy link
Copy Markdown

@ruudk ruudk commented Mar 12, 2026

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:

 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.

ruudk added 2 commits March 12, 2026 11:21
…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.
@ruudk
Copy link
Copy Markdown
Author

ruudk commented Mar 12, 2026

@Wilfred This one is ready whenever you are :) Thanks for making diffs fantastic 😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant