-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Use background color to show colored spaces in an inline diff #4287
Conversation
Darn. Too early. This function is also used to color the summary. I will have to fix this pull request. Don't use it yet. |
the color() function is also used by the summary etc.
From the description I like this change very much. Maybe you could add a screenshot to highlight the difference in output. I do have some reservations though. We are using https://www.npmjs.com/package/diff to create the diffing output. Might such an really belong in the diffing library instead? What happens when I copy/paste the output from the diff? Will I get spaces or will I get |
Good points. Regarding your first: no, I don't think so. Regarding copy&paste: yes, obviously you will get |
I like the diffs from https://unexpected.js.org/assertions/string/to-be/ better, where they are using color inversion to turn the background colored. This highlights spaces very well: |
Ah, interesting! I have wondered if I should do that instead but did not because it seems more like a break with the current way. However, if no one objects, I'll update the pull request. |
It's certainly a change that people will notice. If it's for the better or worse I guess is up to interpretation. Should probably have @mochajs/core weigh in on this |
Hmm. Can you show black-on-red as well? I think I like this idea better than using some random unicode character. |
I think the inversion produces a clearer separation for inline diffs in addition to the fix for whitespace. |
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 think this is an improvement as well. +1 for merging
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.
If I have understood correctly this PR is about inlineDiff
only, not the normal diff
.
So why we don't leave the colors for the normal diff
unchanged, and only change the colors for inlineDiff
?
I'm OK with it changing the colors for all diffs, but we should make sure that's the intent here (it does not seem to be, at least from the title). @michael-brade ? |
fc84532
to
166ff91
Compare
Well, I don't mind either way. But it makes sense to change only the inline diff, so now I updated the 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.
Linting is broken in base.js
.
Fixed. |
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.
@michael-brade I tested your changes, it really looks nice.
I have a small comment, then this PR should be ready to get merged.
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.
@michael-brade thank you
Sorry, I was in a hurry before, that's why I left no comment. Thanks for merging! :-) |
Description of the Change
The
inlineDiffs
option is really nice, showing us in color the added/deleted parts. However, if only whitespace has changed, the diffs are useless because nothing is colored. So this little change replaces all whitespace with the unicode Open Box char.Alternate Designs
n.a.
Why should this be in core?
The functionality already is in core.
Benefits
see above.
Possible Drawbacks
none.
Applicable issues
This is an enhancement.