-
-
Notifications
You must be signed in to change notification settings - Fork 166
[Logs] Highlight inline differences in CLI #1974
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
Conversation
@@ -1,5 +1,10 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<files psalm-version="5.11.0@c9b192ab8400fdaf04b2b13d110575adc879aa90"> | |||
<file src="src/Differ/DiffColorizer.php"> | |||
<InvalidArrayOffset> | |||
<code>$lines[$prevIndex]</code> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know why PSalm doesn't get the Assert::greaterThan($index, 0);
@@ -285,7 +285,7 @@ public static function create(): self | |||
$container->getPrinter(), | |||
$container->getMutantCodeFactory(), | |||
), | |||
Differ::class => static fn (): Differ => new Differ(new BaseDiffer(new UnifiedDiffOutputBuilder())), | |||
Differ::class => static fn (): Differ => new Differ(new BaseDiffer(new UnifiedDiffOutputBuilder(''))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope you are ok removing the "--- Original\n+++ New\n"
header, which only adds visual clutter to the output
b7e0208
to
7ba20b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works just awesome. Thank you very much @Slamdunk
A couple of real-world examples that became very easy to understand:
or this one
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [infection/infection](https://togithub.com/infection/infection) | `^0.29.1` -> `^0.29.2` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>infection/infection (infection/infection)</summary> ### [`v0.29.2`](https://togithub.com/infection/infection/releases/tag/0.29.2): Highlight inline differences in CLI [Compare Source](https://togithub.com/infection/infection/compare/0.29.1...0.29.2) **Added:** - \[Logs] Highlight inline differences in CLI by [@​Slamdunk](https://togithub.com/Slamdunk) in [https://github.com/infection/infection/pull/1974](https://togithub.com/infection/infection/pull/1974) **Full Changelog**: infection/infection@0.29.1...0.29.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/Lendable/json-serializer). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
I'll miss that everyday in PHPUnit now 🤣 |
…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.
…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.
…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.
…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.
…ultiline diffs. (#2000) 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.
Fix #1810
Infection's use case is much more limited: diffs are one-line only, and within the same line only one difference can happen.
Yes the algorithm in this PR needs some time to get understood, but less than tracking and maintaining another dependency.