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

Fix redundant CR in formatted text copy #4190

Merged
1 commit merged into from
Jan 14, 2020

Conversation

mcpiroman
Copy link
Contributor

Summary of the Pull Request

When GenHTML or GenRTF encountered an empty line, they assumed that CR is the last character of the row and wrote it, even though in general CR and LF just break the line and instead of them either <BR> in HTML or \line in RTF is written. Don't know how I missed that in #2038.

Another question is whether the TextAndColor structure which these methods receive and which is generated by TextBuffer::GetTextForClipboard should really contain \r\n at the end of each row. I think it'd be cleaner if it didn't esp. that afaik these last 2 characters don't have associated valid color information.

References

PR Checklist

Validation Steps Performed

Copied various terminal states and verified the generated HTML.

@mcpiroman mcpiroman changed the title Fix redundant CR in formatted text copy Fix redundant CR in formatted text copy Jan 12, 2020
@zadjii-msft
Copy link
Member

@msftbot make sure @carlos-zamora signs off on this

@ghost ghost added the AutoMerge Marked for automatic merge by the bot when requirements are met label Jan 13, 2020
@ghost
Copy link

ghost commented Jan 13, 2020

Hello @zadjii-msft!

Because you've given me some instructions on how to help merge this pull request, I'll be modifying my merge approach. Here's how I understand your requirements for merging this pull request:

  • I'll only merge this pull request if it's approved by @carlos-zamora

If this doesn't seem right to you, you can tell me to cancel these instructions and use the auto-merge policy that has been configured for this repository. Try telling me "forget everything I just told you".

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

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

Seems reasonable to me. I don't know if we have tests for this code - if we did, this seems like something where a test would be really helpful, but if we don't have tests already then ¯\_(ツ)_/¯

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks!

@miniksa
Copy link
Member

miniksa commented Jan 13, 2020

Reran failed jobs. @DHowett-MSFT, it's the privileged instruction thing again. Maybe there's some memory corruption in these tests causing it to jump occasionally to a privileged instruction?

@miniksa
Copy link
Member

miniksa commented Jan 14, 2020

I'm not sure how the PR merge magic works but now that #4202 is merged, I'm re-running the x86 build right now hoping that the updated merge with master will pass the test.

If not, we might need to merge master into this branch first before it'll be happy.

@ghost ghost merged commit 1ca2912 into microsoft:master Jan 14, 2020
DHowett-MSFT pushed a commit that referenced this pull request Jan 24, 2020
## Summary of the Pull Request

When `GenHTML` or `GenRTF` encountered an empty line, they assumed that `CR` is the last character of the row and wrote it, even though in general `CR` and `LF` just break the line and instead of them either `<BR>` in HTML or `\line` in RTF is written. Don't know how I missed that in #2038.

Another question is whether the `TextAndColor` structure which these methods receive and which is generated by `TextBuffer::GetTextForClipboard` should really contain `\r\n` at the end of each row. I think it'd be cleaner if it didn't esp. that afaik these last 2 characters don't have associated valid color information.

## References

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [X] Closes #4187
* [X] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed - there aren't any related tests, right?
* [ ] Requires documentation to be updated
* [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #4147

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
Copied various terminal states and verified the generated HTML.

(cherry picked from commit 1ca2912)
@ghost
Copy link

ghost commented Jan 27, 2020

🎉Windows Terminal Preview v0.8.10261.0 has been released which incorporates this pull request.:tada:

Handy links:

@DHowett-MSFT
Copy link
Contributor

🎉 Once again, thanks for the contribution!

This pull request was included in a set of conhost changes that was just
released with Windows Insider Build 19603.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AutoMerge Marked for automatic merge by the bot when requirements are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

\r ends up unescaped in formatted copy on blank lines
5 participants