Skip to content

Remove color escape after newline from diff line #2

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

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

whwalter
Copy link

This returns the output color to neutal after writing a format line and removes the need for an equalFormat color code.

addFormat = "\x1b[32m+%s" // Foreground Green
removeFormat = "\x1b[31m-%s" // Foreground Red
equalFormat = "\x1b[0m %s" // No Color
addFormat = "\x1b[32m+%s\x1b[0m" // Foreground Green

Choose a reason for hiding this comment

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

what does this do, reset the color?

Copy link
Author

Choose a reason for hiding this comment

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

Yes it removes the color code. Since this is a line level diff we should be able to add and remove the color code for each write and have a line level color code. We need to remove it to cover the case where the diff hits EOF and no additional context lines would be written. In that case, we don't want to leave the foreground color in the + or - color or the next addition to that text buffer/string will also be in that color.

Choose a reason for hiding this comment

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

got it, agreed

@whwalter whwalter requested a review from richerve November 23, 2021 12:14
@whwalter whwalter merged commit e0cd83b into mongodb-forks:master Sep 25, 2024
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