Skip to content

Add ability to suppress line numbers from diff #69

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

Closed
ericbiewener opened this issue Mar 13, 2019 · 3 comments
Closed

Add ability to suppress line numbers from diff #69

ericbiewener opened this issue Mar 13, 2019 · 3 comments

Comments

@ericbiewener
Copy link
Contributor

When diffing component state, I get something that looks like this because only this single line changed in the dom:

@@ -89,1 +89,1 @@
-                   class="MuiSelect-root-180 bold red-500"
+                   class="MuiSelect-root-230 bold tp-green-500"

That's great! But if I modify an unrelated part of the component that results in additional lines of DOM before the class name change that I'm actually concerned about, the diff breaks because the @@ -89,1 +89,1 @@ line number may have become @@ -93,1 +93,1 @@.

Can we add an option to suppress the line numbers?

@thymikee
Copy link
Member

The patchmarks (@@ -93,1 +93,1 @@) come directly from jest-diff. I think we could introduce an option to strip them, why not! Can you make it happen? 😃

@ericbiewener
Copy link
Contributor Author

I'll take a whack at it in the next couple of days 👍

@thymikee
Copy link
Member

Awesome!

thymikee pushed a commit that referenced this issue Mar 15, 2019
Solves #69.

I'm identifying patch marks with a simple regex that looks for a line starting with `@`. This seems safe since `jest-diff` appears to add whitespace at the start of all lines. Therefore, even a line of content that begins with `@` will end up padded with whitespace in the diff itself.

And rather than simply stripping out the patchmarks, I'm replacing them with `-------------`. Since the point of this is to avoid broken diffs, this solves that issue while still giving some indication that there are hidden lines in between those parts of the diff. Perhaps there's a better replacement indicator than that. We could certainly preserve the patch mark `@@` notation like `@@ ------------- @@` if we think that helps communicate the meaning of the new mark.
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

No branches or pull requests

2 participants