-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Issue 1553: Include terminal newlines in diffs #1634
Issue 1553: Include terminal newlines in diffs #1634
Conversation
Note: the linting will fail because we added @RedBeardCode to Changelog links in another PR. |
@tomviner could you please fix the conflicts? 😁 |
@@ -225,9 +225,11 @@ def _diff_text(left, right, verbose=False): | |||
'characters in diff, use -v to show') % i] | |||
left = left[:-i] | |||
right = right[:-i] | |||
# We set splitlines' keepends=True, which can only be passed as a | |||
# positional argument |
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.
In this cases I usually just write:
splitlines = True
...
left.splitlines(splitlines)
But really is just a matter of style, no need to change it. 😁
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.
Thanks @nicoddemus Nice suggestion, applied.
@tomviner could you please rebase/resolve conflicts on this branch? Thanks! |
b13a046
to
608d393
Compare
608d393
to
98adf20
Compare
@nicoddemus rebased :-) |
@tomviner this failed on Windows... if you like, you can sit near me and we can debug it from my laptop. |
@nicoddemus yes please. It maybe Windows line ending related. |
Actually it didn't even run because of some error in AppVeyor. Going to run it locally and see what happens. |
Done, thanks! |
Fix for #1553
By default Python's splitlines method splits so "a terminal line break does not result in an extra line". This means that comparing strings that differ only in whether they contain a terminal newline, results in a bad diff.
This PR sets splitlines'
keepends=True
, which keeps all newlines when splitting.