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

Convert Pasted Line Endings and then send to compty #2390

Closed
wants to merge 15 commits into from
Closed

Convert Pasted Line Endings and then send to compty #2390

wants to merge 15 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 10, 2019

Summary of the Pull Request

This is from a PR request by @d-bingham. However, there have been 89 commits since then, and there are merge conflicts that have not been attended to in a month, and I think converting pasted line endings is a neat idea, so this PR has the changes in PR#1094, but rebased to be current.

References

PR#1094

PR Checklist

  • Closes Pasted text includes CRLF pairs where unneeded #1091
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • 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.

Detailed Description of the Pull Request / Additional comments

@d-bingham said

The new option, convertPasteLineEndings does what it says -- replacing Windows-space CRLF pairs with Unix-space LFs in text pasted to the console. This option applies to both the keyboard-shortcut paste and the right-click paste. Without this most multiline text pasted into Terminal will be "double-spaced" due to the Windows-style CRLF pairs. Furthermore, any multiline text copied from Terminal (in trim whitespace mode) generates CRLF pairs, which guarantees double-spacing when copying from a WSL Terminal session.
Changes:

  • Added TermControl::_SendPastedTextToConnection which adds a pre-processing layer on top of _SendInputToConnection to allow line-ending conversion
  • Various code in Profile/TerminalSettings to support the new option "convertPasteLineEndings" (optional, defaults to false)

Validation Steps Performed

I performed manual and automated testing to ensure this would not break any current code.

@ghost
Copy link
Author

ghost commented Aug 13, 2019

cc: @zadjii-msft, I would like to get your input, as conpty does no such thing.

@ghost
Copy link
Author

ghost commented Aug 15, 2019

@DHowett May I please get your opinion on this too?

@DHowett-MSFT
Copy link
Contributor

Hey, so, I just had a look at a bunch of other terminal emulators. It looks like they all (unconfigurably!) transform \n to \r (on Linux) and \r\n to just \r (on Windows). I think we can safely do that and not need to introduce a new setting.

Here's why I think that: Windows Terminal wants to be a standards-compliant--or, as compliant as it can be--terminal emulator. It should act in every way like every other terminal emulator. If that means that it only ever sends an enter keypress as CR (\r), so be it.

By making Windows Terminal compliant with specified standard (search for | CR to get to the keyboard section), we can leave the compatibility work of translating CR back into CRLF for Windows applications in ConPTY.

Also, unrelatedly, it is very hard for us to accept pull requests that also make unrelated code style and formatting changes. Please try to refrain from doing that!
Thanks.

@DHowett-MSFT DHowett-MSFT added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 15, 2019
@ghost
Copy link
Author

ghost commented Aug 17, 2019

So we should put this functionality in Conpty? got it.

@ghost ghost removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 17, 2019
@DHowett-MSFT
Copy link
Contributor

Wait no! Conpty handles this correctly (translating \r to Enter), so Terminal should always translate \r\n to \r. We don’t need a configuration option for it :)

@ghost
Copy link
Author

ghost commented Aug 17, 2019

Ok, got it. so no need to do this here, right?

@DHowett-MSFT
Copy link
Contributor

Right, we just need to make convertPasteLineRndibgs the default and remove the option to disable it.

@DHowett-MSFT
Copy link
Contributor

I did mean “endings” 😄

@chiefjester
Copy link

oh wow, we need this! 😱

@DHowett-MSFT DHowett-MSFT added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Sep 13, 2019
@ghost ghost added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Sep 13, 2019
@ghost
Copy link

ghost commented Sep 13, 2019

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@ghost
Copy link
Author

ghost commented Sep 13, 2019

So should I go and do those changes? Or is there work being done already

@ghost ghost removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. labels Sep 13, 2019
@DHowett-MSFT
Copy link
Contributor

@pi1024e we’d love that! No work is ongoing here.

@DHowett-MSFT DHowett-MSFT mentioned this pull request Oct 15, 2019
5 tasks
@DHowett-MSFT
Copy link
Contributor

I'm going to close this one out -- please let me know if you still want to work on the final iteration! If not, I might make an attempt at it myself. 😄

@ghost
Copy link
Author

ghost commented Oct 30, 2019

I am going to open a new PR following your advice. Thank you!

zadjii-msft pushed a commit that referenced this pull request Nov 6, 2019
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? -->
## Summary of the Pull Request

<!-- Other than the issue solved, is this relevant to any other issues/existing PRs? --> 
## References

#1091 
#1094 
#2390 
#3314

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
* [x] Closes #1091
* [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA
* [ ] Tests added/passed
* [ ] Requires documentation to be updated
* [x] 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: #xxx

<!-- Provide a more detailed description of the PR, other things fixed or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments

Combination of the PRs #1094, #2390, and #3314, especially as discussed in #3314.

In short, this changes line endings from Windows-space \r\n to the more universal \r.

<!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed

Copied and pasted text into the terminal without the patch, line endings were doubled.
With the patch, line endings weren't doubled.


--------------------

* Replacing \r\n line endings with \r line endings

* Fixing Formatting
@zadjii-msft zadjii-msft mentioned this pull request Nov 19, 2019
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.

Pasted text includes CRLF pairs where unneeded
4 participants