8000 Fallback to the simple diff colorizer (previous implementation) for multiline diffs by maks-rafalko · Pull Request #2000 · infection/infection · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fallback to the simple diff colorizer (previous implementation) for multiline diffs #2000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2024

Conversation

maks-rafalko
Copy link
Member
@maks-rafalko maks-rafalko commented Oct 6, 2024

Fixes #1999

We introduced inline highlighter for diffs in #1974 (thanks to @Slamdunk). However, there was an incorrect assumption that we only have one-line diffs. This is not true.

The case which is currently fails is the following:

@@ @@
      */
     protected function name()
     {
-        return strtolower(get_class($this));
+        strtolower(get_class($this));
+        return null;
     }
 }

I checked how diff-so-fancy works with multiline diffs, and it turned out that it just skips inline diffs, using simple algorithm, see images below.

diff-so-fancy for multiline case (now we have the same result after this MR):

image

diff-so-fancy for one-line case (we have the same result):

image

So, for the cases when we have multiline diffs, I just added fallback - our old algorithm of colorizing diffs.


I've tested this patch with @sanmai's reproducer, it works fine:

vendor/bin/infection --min-msi=80 --min-covered-msi=80 --show-mutations -jmax -vvv --mutators=FunctionCall --filter=AbstractTag
image

@maks-rafalko maks-rafalko requested a review from sanmai October 6, 2024 11:51
@maks-rafalko maks-rafalko force-pushed the bugfix/multiline-diff-colorizer branch 2 times, most recently from 56805fa to 151b814 Compare October 6, 2024 11:59
…ultiline diffs.

We introduced inline highlighter for diffs in #1974 (thanks to @Slamdunk). However, there was an incorrect assumption that we only have one-line diffs. This is not true.

The case which is currently fails is the following:

```diff
@@ @@
      */
     protected function name()
     {
-        return strtolower(get_class($this));
+        strtolower(get_class($this));
+        return null;
     }
 }
```

I check how `diff-so-fancy` works with multiline diffs, and it turned out that it just skips inline diffs, using simple algorithm, see images below.

So, for the cases when we have multiline diffs, I just added fallback - our old algorithm of colorizing diffs.
@maks-rafalko maks-rafalko force-pushed the bugfix/multiline-diff-colorizer branch from 151b814 to 2b6448e Compare October 6, 2024 12:01
Copy link
Member
@sanmai sanmai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

@maks-rafalko maks-rafalko enabled auto-merge (squash) October 6, 2024 12:09
@maks-rafalko maks-rafalko merged commit 243d501 into master Oct 6, 2024
70 checks passed
@maks-rafalko maks-rafalko deleted the bugfix/multiline-diff-colorizer branch October 6, 2024 12:20
@Slamdunk
Copy link
Contributor
Slamdunk commented Oct 6, 2024

I'm so sorry I missed this case. I'm glad you found a quick solution 👍

@maks-rafalko
Copy link
Member Author
maks-rafalko commented Oct 6, 2024

no worries, thanks for this feature. Love it ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

InvalidArgumentException in DiffColorizer
3 participants
0