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

Remove trailing \r from raw line, in presence of ANSI escape sequences #800

Merged
merged 1 commit into from
Nov 25, 2021

Conversation

dandavison
Copy link
Owner

Fixes #795 cc @th1000s

// Thus byte_lines library can't remove the CR properly.)
if let Some(b'\r') = self.line.bytes().nth_back(0) {
self.line.truncate(self.line.len() - 1);
}
}
Copy link
Owner Author

@dandavison dandavison Nov 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I owe some tests, but we can see that with this commit we are still fixing the git add -p bug #664 that was the reason for the addition of the lines above (now deleted and replaced by the lines further above):

git add a.py && git commit -m .
mv b.py a.py

Without any \r-stripping, notice that one of the lines is not rendered due to the \r:

image
With the code after this commit:
image

@dandavison dandavison merged commit f65f312 into master Nov 25, 2021
@dandavison dandavison deleted the 795-strip-trailing-cr-from-raw-line branch November 25, 2021 16:12
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.

🐛 git's --color-moved with DOS line endings (\r\n) triggers a panic
1 participant