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 #2009

Closed
wants to merge 33 commits into from
Closed

Convert pasted line endings #2009

wants to merge 33 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jul 17, 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

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

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 a manual test, ensuring this would not break any current code.

@ghost
Copy link
Author

ghost commented Jul 20, 2019

cc @DHowett-MSFT

@ghost
Copy link
Author

ghost commented Jul 21, 2019

Could someone please review this PR. Thank you!

@DHowett-MSFT
Copy link
Contributor

@pi1024e I appreciate your excitement, but it’s the weekend here in Redmond where most of the team works. We try not to work too much outside normal working hours.

@ghost
Copy link
Author

ghost commented Jul 23, 2019

Ok, is this good, or are there any requested changes?

@miniksa
Copy link
Member

miniksa commented Jul 24, 2019

It looks like @zadjii-msft and @DHowett-MSFT had outstanding concerns with #1094 and whether it was even being solved in the right place. As such, I'm deferring to them to review this and decide how to proceed.

@DHowett-MSFT
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ghost
Copy link
Author

ghost commented Jul 27, 2019

fixed

@ghost
Copy link
Author

ghost commented Jul 30, 2019

Rebased to be current. I hope these changes are appropriate!

@zadjii-msft
Copy link
Member

So for the record, @DHowett-MSFT mentioned in #1094

I'm not sure this needs to be a setting. conpty should be turning <CR> into the right format on the other end. Maybe this is important for other types of connections?

And I concur that's a good hypothesis to investigate. So I don't really want to merge this without first investigating if conpty can just make this happen automatically.

@ghost
Copy link
Author

ghost commented Aug 5, 2019

Conpty does not, and I checked. The question now is: should I change this so the functionality is moved to conpty, or is this good as is?

@zadjii-msft
Copy link
Member

I would definitely want to make sure the conpty option is investigated first. I don't really have an idea of where to investigate that at the moment - I'd think we'd need to be smarter in the InteractDispatch/InputBuffer area about text that's input from conpty. We'd probably want to take into account the input mode that's set by the client app (if we're not already).

I'd want to know what input records the InputStateMachineEngine is generating for pasted text with newline/carriage returns, and how the input buffer processes that text (compared to a normal conhost window).

@zadjii-msft
Copy link
Member

@pi1024e I'm going to close this PR for the time being. If you do investigate the conpty copy-paste and find a suitable solution, feel free to open another, or if you find that the conpty route is a dead end, I'd love to see an update on this thread. In the latter case, we'll be happy to re-open this PR.

@zadjii-msft zadjii-msft closed this Aug 8, 2019
@ghost
Copy link
Author

ghost commented Aug 8, 2019

Looking at the conpty, I found it does nothing of the sort. That being written, I don't know if I should start over and add this functionality to conpty or keep it here.

@ghost
Copy link
Author

ghost commented Aug 8, 2019

Pasted line endings only really happen when being pasted as input, so I do not think conpty should do that.

@ghost
Copy link
Author

ghost commented Aug 8, 2019

This appears to be the best solution I can come up with

@ghost
Copy link
Author

ghost commented Aug 8, 2019

No, conpty does not fix the line endings

@ghost
Copy link
Author

ghost commented Aug 9, 2019

cc @zadjii-msft

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