Skip to content
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

printer: do not print inline diff for multiline insert/delete chunks #66

Merged
merged 1 commit into from
Mar 9, 2021

Conversation

tommilligan
Copy link
Collaborator

Inline diffing with the boundary of multiline chunks looks bad, and is counter-intuitive. For this reason, most diff implementations don't do it (such as Github).

We also shouldn't do this kind of inline diffing if there are more lines deleted preceding, or more lines inserted following, the boundary.

image

@codecov-io
Copy link

Codecov Report

Merging #66 (8f7d7a5) into main (7f6ae17) will decrease coverage by 0.43%.
The diff coverage is 97.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #66      +/-   ##
==========================================
- Coverage   99.39%   98.96%   -0.44%     
==========================================
  Files           2        2              
  Lines         166      193      +27     
==========================================
+ Hits          165      191      +26     
- Misses          1        2       +1     
Impacted Files Coverage Δ
src/printer.rs 99.24% <97.22%> (-0.76%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7f6ae17...8f7d7a5. Read the comment docs.

@tommilligan tommilligan merged commit fdff5f3 into rust-pretty-assertions:main Mar 9, 2021
bors bot referenced this pull request in jonasbb/serde_with Mar 13, 2021
279: Update pretty_assertions requirement from 0.6.1 to 0.7.1 r=jonasbb a=dependabot[bot]

Updates the requirements on [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) to permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/colin-kiegel/rust-pretty-assertions/releases">pretty_assertions's releases</a>.</em></p>
<blockquote>
<h2>v0.7.1</h2>
<h2>Fixed</h2>
<ul>
<li>Fix a bug where multiline changes showed an unhelpful inline diff (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/66">#66</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md">pretty_assertions's changelog</a>.</em></p>
<blockquote>
<h1>v0.7.1</h1>
<ul>
<li>Fix a bug where multiline changes showed an unhelpful inline diff (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/66">#66</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<h1>v0.7.0</h1>
<h2>Changed</h2>
<ul>
<li>Move from <code>difference</code> to <code>diff</code> for calculating diffs. The exact assertion messages generated may differ from previous versions. (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/52">#52</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<p>For example, the following assertion message from <code>v0.7.0</code>:</p>
<p><img src="https://raw.githubusercontent.com/colin-kiegel/rust-pretty-assertions/2d2357ff56d22c51a86b2f1cfe6efcee9f5a8081/examples/pretty_assertion.png" alt="pretty assertion" /></p>
<p>Was previously rendered like this in <code>v0.6.1</code>:</p>
<p><img src="https://raw.githubusercontent.com/colin-kiegel/rust-pretty-assertions/2d2357ff56d22c51a86b2f1cfe6efcee9f5a8081/examples/pretty_assertion_v0_6_1.png" alt="pretty assertion" /></p>
<h2>Added</h2>
<ul>
<li>Support for unsized values (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/42">#42</a>, <a href="https://github.com/stanislav-tkach"><code>@​stanislav-tkach</code></a>)</li>
<li>Document the <code>Comparison</code> struct, which was previously hidden. This can be used to generate a pretty diff of two values without panicking. (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/52">#52</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<h2>Fixed</h2>
<ul>
<li>Fix some unhygenic macro expansions (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/41">#41</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<h2>Internal</h2>
<ul>
<li>Test Windows targets in CI (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/46">#46</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
<li>Bump <code>ansi_term</code> version to 0.12 (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/34">#34</a>, <a href="https://github.com/waywardmonkeys"><code>@​waywardmonkeys</code></a>)</li>
<li>Code health improvements (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/34">#34</a>, <a href="https://github.com/waywardmonkeys"><code>@​waywardmonkeys</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/2667441b0edb3322eab7d7779a3a96c280414ddf"><code>2667441</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/68">#68</a> from tommilligan/prep-v0.7.1</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/6dde470f579a2bf88251a6e4eb1a691be3d19920"><code>6dde470</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/67">#67</a> from tommilligan/ci-revert-cargo-target-dir</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/b517e396dbbce136a27756732080a1a592e74eca"><code>b517e39</code></a> chore: prepare for v0.7.1</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/fdff5f32f967a171cbb59dbb18e814532bf594a5"><code>fdff5f3</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/66">#66</a> from tommilligan/chunk-diffing</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/62e93575ffc081c36f779da188057a51df555734"><code>62e9357</code></a> Revert &quot;ci: remove concern with CARGO_TARGET_DIR&quot;</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/8f7d7a5ee00a2e36885fc016fb13e91c062dd7ae"><code>8f7d7a5</code></a> printer: do not print inline diff for multiline insert/delete chunks</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/083ce2ebe4892fb219f36beb764065920de0f96b"><code>083ce2e</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/65">#65</a> from tommilligan/ci-rm-cargo-target-dir</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/56a0aaa6185e2e5db46aef54fb61a4388f89943f"><code>56a0aaa</code></a> ci: remove concern with CARGO_TARGET_DIR</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/7f6ae17e0046d1ddb55291cf7ea7064c8630fbf5"><code>7f6ae17</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/63">#63</a> from tommilligan/update-gitignore</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/ccb2e45112471740a61ce82565ab5ffe916c6d3d"><code>ccb2e45</code></a> ci: update gitignore</li>
<li>Additional commits viewable in <a href="https://github.com/colin-kiegel/rust-pretty-assertions/compare/v0.6.1...v0.7.1">compare view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
bors bot referenced this pull request in jonasbb/rust_misc_utils Mar 13, 2021
62: Update pretty_assertions requirement from 0.6 to 0.7 r=jonasbb a=dependabot[bot]

Updates the requirements on [pretty_assertions](https://github.com/colin-kiegel/rust-pretty-assertions) to permit the latest version.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/colin-kiegel/rust-pretty-assertions/releases">pretty_assertions's releases</a>.</em></p>
<blockquote>
<h2>v0.7.1</h2>
<h2>Fixed</h2>
<ul>
<li>Fix a bug where multiline changes showed an unhelpful inline diff (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/66">#66</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/colin-kiegel/rust-pretty-assertions/blob/main/CHANGELOG.md">pretty_assertions's changelog</a>.</em></p>
<blockquote>
<h1>v0.7.1</h1>
<ul>
<li>Fix a bug where multiline changes showed an unhelpful inline diff (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/66">#66</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<h1>v0.7.0</h1>
<h2>Changed</h2>
<ul>
<li>Move from <code>difference</code> to <code>diff</code> for calculating diffs. The exact assertion messages generated may differ from previous versions. (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/52">#52</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<p>For example, the following assertion message from <code>v0.7.0</code>:</p>
<p><img src="https://raw.githubusercontent.com/colin-kiegel/rust-pretty-assertions/2d2357ff56d22c51a86b2f1cfe6efcee9f5a8081/examples/pretty_assertion.png" alt="pretty assertion" /></p>
<p>Was previously rendered like this in <code>v0.6.1</code>:</p>
<p><img src="https://raw.githubusercontent.com/colin-kiegel/rust-pretty-assertions/2d2357ff56d22c51a86b2f1cfe6efcee9f5a8081/examples/pretty_assertion_v0_6_1.png" alt="pretty assertion" /></p>
<h2>Added</h2>
<ul>
<li>Support for unsized values (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/42">#42</a>, <a href="https://github.com/stanislav-tkach"><code>@​stanislav-tkach</code></a>)</li>
<li>Document the <code>Comparison</code> struct, which was previously hidden. This can be used to generate a pretty diff of two values without panicking. (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/52">#52</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<h2>Fixed</h2>
<ul>
<li>Fix some unhygenic macro expansions (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/41">#41</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
</ul>
<h2>Internal</h2>
<ul>
<li>Test Windows targets in CI (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/46">#46</a>, <a href="https://github.com/tommilligan"><code>@​tommilligan</code></a>)</li>
<li>Bump <code>ansi_term</code> version to 0.12 (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/34">#34</a>, <a href="https://github.com/waywardmonkeys"><code>@​waywardmonkeys</code></a>)</li>
<li>Code health improvements (<a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/34">#34</a>, <a href="https://github.com/waywardmonkeys"><code>@​waywardmonkeys</code></a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/2667441b0edb3322eab7d7779a3a96c280414ddf"><code>2667441</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/68">#68</a> from tommilligan/prep-v0.7.1</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/6dde470f579a2bf88251a6e4eb1a691be3d19920"><code>6dde470</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/67">#67</a> from tommilligan/ci-revert-cargo-target-dir</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/b517e396dbbce136a27756732080a1a592e74eca"><code>b517e39</code></a> chore: prepare for v0.7.1</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/fdff5f32f967a171cbb59dbb18e814532bf594a5"><code>fdff5f3</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/66">#66</a> from tommilligan/chunk-diffing</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/62e93575ffc081c36f779da188057a51df555734"><code>62e9357</code></a> Revert &quot;ci: remove concern with CARGO_TARGET_DIR&quot;</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/8f7d7a5ee00a2e36885fc016fb13e91c062dd7ae"><code>8f7d7a5</code></a> printer: do not print inline diff for multiline insert/delete chunks</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/083ce2ebe4892fb219f36beb764065920de0f96b"><code>083ce2e</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/65">#65</a> from tommilligan/ci-rm-cargo-target-dir</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/56a0aaa6185e2e5db46aef54fb61a4388f89943f"><code>56a0aaa</code></a> ci: remove concern with CARGO_TARGET_DIR</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/7f6ae17e0046d1ddb55291cf7ea7064c8630fbf5"><code>7f6ae17</code></a> Merge pull request <a href="https://github.com/colin-kiegel/rust-pretty-assertions/issues/63">#63</a> from tommilligan/update-gitignore</li>
<li><a href="https://github.com/colin-kiegel/rust-pretty-assertions/commit/ccb2e45112471740a61ce82565ab5ffe916c6d3d"><code>ccb2e45</code></a> ci: update gitignore</li>
<li>Additional commits viewable in <a href="https://github.com/colin-kiegel/rust-pretty-assertions/compare/v0.6.0...v0.7.1">compare view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@tommilligan tommilligan deleted the chunk-diffing branch May 1, 2021 07:32
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.

2 participants