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

Terminal doesn't translate LF to CR on paste; it only translates CRLF #5821

Closed
riverar opened this issue May 9, 2020 · 10 comments · Fixed by #8634
Closed

Terminal doesn't translate LF to CR on paste; it only translates CRLF #5821

riverar opened this issue May 9, 2020 · 10 comments · Fixed by #8634
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Impact-Correctness It be wrong. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@riverar
Copy link

riverar commented May 9, 2020

Notes from @DHowett-MSFT:

Line ending conversions by other terminals

Clipboard Contains xterm sends wt sends putty sends gnome-terminal sends conhost sends
\r\n (CRLF) \r ✔️ \r ✔️ \r ✔️ \r ✔️ \r ✔️
\r (CR) \r ✔️ \r ✔️ \r ✔️ \r ✔️ \r ✔️
\n (LF) \r ✔️ \n \n \r ✔️ \r ✔️

I guess that means that both of WT and putty are wrong 😄

--- original filing below ---

Environment

Windows 10 10.0.19041.207
Windows Terminal 0.11.1251.0

Steps to reproduce

  1. Open Windows Terminal (Windows PowerShell or PowerShell Core).
  2. Copy all the text in the attached file fake_key.txt.
  3. Paste into Windows Terminal with the mouse.
  4. Observe the lines appear in reverse order.

Expected behavior

Similar behavior to cmd.exe and wsl, in that the pasted lines are in original order and intact.

Actual behavior

Bamboozled. Lines are presented in reverse order.

Screenshots

image

image

image

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 9, 2020
@skyline75489
Copy link
Collaborator

Stock powershell.exe shares the same behavior. Also seen this in PowerShell Core 7.

@DHowett-MSFT
Copy link
Contributor

That is strange. I would call that CMD and WSL work properly evidence that it is possible for the shell to either mess this up or fix it, so...

@DHowett-MSFT
Copy link
Contributor

Rafael, if you Remove-Module PSReadline, do you get the result you’re expecting?

@skyline75489
Copy link
Collaborator

skyline75489 commented May 9, 2020

I was about to add that. But I wouldn't really say "CMD and WSL works property". First, in CMD the \n is completely ignored. Second, in WSL the '\n' is treated as an actual Enter, causing many command not found complaints from bash.

To me, PSReadline does not seem to matter. . I concur with @riverar . PSReadline does matter. I'm using it without being awareness.

@riverar
Copy link
Author

riverar commented May 9, 2020

Results with PSReadline removed:

PowerShell Core (correct order, but truncated)
image

Windows PowerShell (correct)
image

@DHowett-MSFT
Copy link
Contributor

Even curiouser: It works "fine" (that is: to the same extent as cmd and without PSReadline) for me on PowerShell 7.0 and 7.1-preview.

I was inclined to call this a miss in our clipboard conversion, but... it looks like there's no consensus here.

Clipboard Contains xterm sends wt sends putty sends gnome-terminal sends
\r\n (CRLF) \r \r \r \r
\r (CR) \r \r \r \r
\n (LF) \r \n \n \r

I guess that means that both of WT and putty are wrong 😄

@DHowett-MSFT
Copy link
Contributor

Well, conhost does it right. I guess that's it then. I'm renaming your bug ;P

@DHowett-MSFT DHowett-MSFT changed the title Lines pasted into Windows Terminal appear in reverse order when LF endings present Terminal doesn't translate LF to CR on paste; it only translates CRLF May 9, 2020
@DHowett-MSFT DHowett-MSFT added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Impact-Correctness It be wrong. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. labels May 9, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 9, 2020
@DHowett-MSFT DHowett-MSFT added this to the Terminal v1.x milestone May 9, 2020
@riverar
Copy link
Author

riverar commented May 9, 2020

Thanks all! A++ would file another bug.

@DHowett-MSFT DHowett-MSFT removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label May 13, 2020
@ghost ghost added the In-PR This issue has a related PR label Jan 7, 2021
@ghost ghost closed this as completed in #8634 Jan 8, 2021
@ghost ghost removed the In-PR This issue has a related PR label Jan 8, 2021
ghost pushed a commit that referenced this issue Jan 8, 2021
- Detect `\r` when warning about multi line paste
- Translate `\n` to `\r` on paste

## PR Checklist
* [x] Closes #8601
* [x] Closes #5821

## Validation Steps Performed
Manual testing
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Jan 8, 2021
DHowett pushed a commit that referenced this issue Jan 25, 2021
- Detect `\r` when warning about multi line paste
- Translate `\n` to `\r` on paste

## PR Checklist
* [x] Closes #8601
* [x] Closes #5821

## Validation Steps Performed
Manual testing

(cherry picked from commit 49d0085)
@ghost
Copy link

ghost commented Jan 28, 2021

🎉This issue was addressed in #8634, which has now been successfully released as Windows Terminal v1.5.10271.0.:tada:

Handy links:

@ghost
Copy link

ghost commented Jan 28, 2021

🎉This issue was addressed in #8634, which has now been successfully released as Windows Terminal Preview v1.6.10272.0.:tada:

Handy links:

mpela81 pushed a commit to mpela81/terminal that referenced this issue Jan 28, 2021
- Detect `\r` when warning about multi line paste
- Translate `\n` to `\r` on paste

## PR Checklist
* [x] Closes microsoft#8601
* [x] Closes microsoft#5821

## Validation Steps Performed
Manual testing
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Impact-Correctness It be wrong. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants