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

Copy and paste from the Windows Terminal doesn't include line breaks #1073

Closed
conioh opened this issue May 30, 2019 · 71 comments · Fixed by #3239
Closed

Copy and paste from the Windows Terminal doesn't include line breaks #1073

conioh opened this issue May 30, 2019 · 71 comments · Fixed by #3239
Assignees
Labels
Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements 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

@conioh
Copy link

conioh commented May 30, 2019

Environment

Windows build number: 10.0.18362.116
Windows Terminal version (if applicable): 71e19cd + changing toolset to v142 and SDK version

Steps to reproduce

  1. Clone, build, package, install and launch Windows Terminal (DevBuild).
  2. Execute docker run --rm -it mcr.microsoft.com/windows/nanoserver:1903
  3. Select multiple lines and right click.
  4. Paste in any text editor. I used VSCode.

Expected behavior

I expected to see the same thing I saw in the terminal - specifically multiple lines.

Actual behavior

One line with lots of space.

Notes

This is different from #65 since it was about conhost and I'm talking about the new terminal, and I didn't have Shift pressed.

@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 30, 2019
@zadjii-msft
Copy link
Member

Huh, I'm not seeing this - @carlos-zamora thoughts?

image

@zadjii-msft zadjii-msft added Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Product-Terminal The new Windows Terminal. labels May 31, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 31, 2019
@d-bingham
Copy link
Contributor

@zadjii-msft There's some terminal state change that causes it. Repro steps:

  1. Open up a bash.exe session
  2. ls -l to generate some multiline text
  3. Select and copy it -- works as expected
  4. edit a file with vi
  5. Select and copy text -- now the endlines are missing

image

I've been well aware of this working on the clipboard stuff, but haven't tracked down the bug yet. The bug probably manifests in TextBuffer::GetTextForClipboard, but I haven't had the time to debug it yet.

@zadjii-msft zadjii-msft removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 3, 2019
@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 Jun 3, 2019
@DHowett-MSFT DHowett-MSFT added this to the Terminal v1.0 milestone Jun 3, 2019
@DHowett-MSFT
Copy link
Contributor

Closing in favor of #1091.

@ghost ghost added the Needs-Tag-Fix Doesn't match tag requirements label Jun 3, 2019
@DHowett-MSFT DHowett-MSFT added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. and removed Needs-Tag-Fix Doesn't match tag requirements labels Jun 3, 2019
@DHowett-MSFT
Copy link
Contributor

It turns out that this is a different issue.

@DHowett-MSFT DHowett-MSFT reopened this Jun 4, 2019
@DHowett-MSFT DHowett-MSFT removed the Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. label Jun 4, 2019
@conioh
Copy link
Author

conioh commented Jun 5, 2019

I edited the issue to add correct instruction to reproduce.
@d-bingham @zadjii-msft, it happens with docker and not only with WSL.
Also happens if I open the console with hcsdiag console id instead of using docker run.

@ljani
Copy link

ljani commented Jun 23, 2019

I'm seeing this as well. My shell is Powershell Core 6.2.0 and everything I try to copy has this problem. It seems that the copy functionality copies the whole buffer. Ie, if I'm trying to copy this:

get-content myfile.txt
Hello
World

123456789012345678901234567890

It copies this, where ^ denotes a space and my terminal is 30 chars wide:

get-content^myfile.txt^^^^^^^^
Hello^^^^^^^^^^^^^^^^^^^^^^^^^
World^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
123456789012345678901234567890

@andrp92
Copy link

andrp92 commented Jun 25, 2019

I'm having same issue. when entering a copied command like:

apt-get install -y make build-essential checkinstall libssl-dev libbz2-dev libzip-dev
libreadline-gplv2-dev libncursesw5-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libffi-dev
wget curl libldap2-dev zlib1g-dev lib32z1-dev uuid-dev

It only runs the very first line... when using WSL directly, works as expected.

@mikepurvis
Copy link

mikepurvis commented Jul 11, 2019

I also have this issue when copying text out of an SSH session to a Linux host.

Currently working around it by having this script on my desktop and giving it a double click when I have something I need to paste out of Terminal:

from pyperclip import copy, paste
from re import sub
copy(sub(' {10,}', '\r\n', paste()))

@hanubeki
Copy link

I think I found an easier reproduce steps.

  1. Open cmd or PowerShell
  2. cls to clear the screen
  3. Run some command that writes output such as dir
  4. Copy output text
  5. Paste to somewhere (e.g. notepad)
  6. Pasted text doesn't include line breaks

@nerddtvg
Copy link

Thank you, @d-bingham, from all of us waiting on the issue.

@pkoscisz
Copy link

Now, can we get feature to move tabs around by using cursor and if you have many tabs they don't hide behind '+' character please! LOL 💃

@DHowett-MSFT
Copy link
Contributor

It's not on-topic for this particular issue, but the tabs are getting a bit of a boost in 0.6. See the tree of issues linked from #3027.

@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. and removed In-PR This issue has a related PR labels Oct 18, 2019
@ghost
Copy link

ghost commented Oct 23, 2019

🎉This issue was addressed in #3239, which has now been successfully released as Windows Terminal Preview v0.6.2951.0.:tada:

Handy links:

@subhanshu-shukla
Copy link

subhanshu-shukla commented Oct 24, 2019 via email

@carlosrmendes
Copy link

yes, I can confirm that still doesn't work on v0.6.2951.0

Copy from VSCode and paste in Windows Terminal on vim:
image

@nerddtvg
Copy link

This bug is not related to pasting into Terminal, it is pasting from Terminal. I believe what you're referring to is discussed in #1091.

@tirelibirefe
Copy link

I use different terminal emulators in Win10 1903 and all of them have the same problem.

Clipboard: govc find / -type m -name 'dev1-' | xargs govc vm.ip -a -v4
Pasted as: govcfind/-typem-name'dev1-
'|xargsgovcv4

@DHowett-MSFT
Copy link
Contributor

Those are definitely not line breaks that you’re missing... would you mind filing a new separate issue and following the issue template? Thanks.

@DHowett-MSFT
Copy link
Contributor

For what it’s worth: if multiple terminal emulators experience the same issue, it’s probably something in your shell.

@subhanshu-shukla
Copy link

subhanshu-shukla commented Nov 20, 2019 via email

@nerddtvg
Copy link

@mikkushukla, please open a new issue to report the problem: https://github.com/microsoft/terminal/issues

@alxtsg
Copy link

alxtsg commented Nov 20, 2019

@mikkushukla

Terminal freezes during post laptop sleep and network disconnect. Every time I have to force kill the app via task manager.
Is this a known issue?

The problem you described is not related to this issue.

@pztrn
Copy link

pztrn commented Dec 8, 2019

Windows Terminal (Preview)
Version: 0.7.3291.0

Still experiencing this.

@subhanshu-shukla
Copy link

subhanshu-shukla commented Dec 8, 2019 via email

@nerddtvg
Copy link

nerddtvg commented Dec 8, 2019

@pztrn, you may be best served opening anew issue and referencing this one. Ensure you provide all relevant information to reproduce the problem.

@mikkushukla: Your statement has nothing to do with this bug report. If you have issues that are unrelated to line breaks in copy and paste functionality, please open a new bug report.

@eromoe
Copy link

eromoe commented May 23, 2020

meet this in terminal 1.0 wsl2 ubuntu 18.04

  1. hold ctrl + shift , use cursor to copy multiple lines. (I mean right click mouse to do quick copy)
  2. paste in vscode or other editors , lose line break

PS:

  1. make selections
  2. ctrl + shift + c did copy the line breaks

@JesusCoyotzi
Copy link

Found this issue too
terminal 1.0

If I copy from terminal pasting preserves multiple lines. But If I am inside vim when copying and pasting the line breaks dissapear. Resulting in one long line.

My full environment is: Windows terminal, powershell, logged via ssh to a linux box that is running tmux and inside is running vim.

@carlos-zamora
Copy link
Member

@JesusCoyotzi could you submit a new bug report here? Please include specific steps on how you performed the copy/paste and what you're running there. Sounds like a real issue but we should be tracking this in more detail separately.

@zd3nik
Copy link

zd3nik commented Jan 9, 2023

I am on a new machine using Windows 11 and I'm experiencing this problem in the WSL console.

  1. Open a WSL console
  2. Do an ls or something to get multiple lines in the console
  3. Select/Copy multiple lines
  4. Paste into any text editor

The pasted text will be one line with spaces between the text that should be on separate lines.

NOTE: I have the Ctrl+Shift+C/V option enabled

image
image
image

@zadjii-msft
Copy link
Member

@zd3nik That's by design for Ctrl+shift+c. See #65 (comment)

Copy-paste is significantly more reasonable and configurable in the Windows Terminal, I'd recommend that. Conhost's copy-paste is pretty significantly burdened by years of legacy behavior.

@zd3nik
Copy link

zd3nik commented Jan 9, 2023

That's unfortunate. Because automatically copying whatever you select into the clipboard is.... not ideal. Especially when simply clicking somewhere in the terminal (say, to put focus on the terminal) highlights part of the terminal text (one character). So I'm constantly blowing whatever useful data I may have had in my clipboard whenever I click on a windows terminal window. Not ideal.

If the terminal was at least smart enough to only highlight when you "drag" the mouse pointer over part of the terminal instead, then it wouldn't be so detrimental to automatically put whatever you highlight into the clipboard.

@zadjii-msft
Copy link
Member

@zd3nik I think you're confusing the vintage Windows Console (conhost.exe) and the modern Windows Terminal. Looking at that screenshot, those are the settings for conhost, not the Terminal. Copying in the console is pretty rachet, yea. But the experience is substantially better in the Terminal. We've already (like, two years ago) made adjustments to how selecting on a click/drag works, to be more like what you suggest. We've made what keys are used for copy/paste configurable, including whether or not a copy copies as a single line or not. I'd give that a try. Seeing as you're on Windows 11, the new Terminal comes with Windows 11, so it should be there already.

@zd3nik
Copy link

zd3nik commented Jan 12, 2023

Thanks for the info @zadjii-msft. Is there a way to select which terminal is used for wsl? I'm just using the terminal that it opens when I launch my wsl console.

@zadjii-msft
Copy link
Member

Check out this blog post

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.) Issue-Bug It either shouldn't be doing this or needs an investigation. Needs-Tag-Fix Doesn't match tag requirements 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.