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

Copying multi-line text and pasting to a file puts all text onto single line #65

Closed
drew-viles opened this issue Feb 13, 2018 · 8 comments
Labels
Product-Conhost For issues in the Console codebase Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.

Comments

@drew-viles
Copy link

drew-viles commented Feb 13, 2018

Your Windows build number:
Microsoft Windows [Version 10.0.16299.192]

What you're doing and what's happening:
When copying a few lines from the centre of a file with Ctrl + Shift + C I'm getting multi-line text put onto a single line.

So in my scenario:

  1. I ssh'd onto a Linux server using the bash for windows terminal.
  2. I'd cat or vim, in this case, a JSON file as there are 6-7 lines I need from the centre of the file.
  3. I then highlight and copy the lines I need with the mouse and Ctrl +Shift + S
  4. I paste it into a file (middle mouse click as Ctrl + Shift + V does not work in insert mode in vim when using WSL)

The issue is that it puts all the multi-line text onto one single line separated by large amounts of white-space rather than discovering the line endings and breaking as required.

This is obviously not expected behaviour and appears to have something to do with the Windows line endings though I can only speculate this based on what I've seen and how I do not see this behaviour happen on my native Linux system.

This happens with or without "Enable 'line wrapping selection" checked and unchecked.
It seems like it is copying all of the white-space around the text even though there is non in the file.

I should note that if, for example, I copy and paste everything I'm writing here right now, it works fine.
It only seems to be when I'm in bash itself and working within that environment.

I've recorded a video of this happening too: https://youtu.be/Z-M5P7ZTJqs

What's wrong / what should be happening instead:
It should paste the multi-line content as multiple lines, not a single long line with lots of white-space.

@bgshacklett
Copy link

bgshacklett commented Feb 23, 2018

In the video, it looks like everything is working as it should. Line breaks are carried over where they exist and the SSH key, which contains no line breaks, remains unbroken. The issue with the whitespace is a problem with the way Vim's automatic indentation works. It can be avoided by running :set paste before pasting the text and running :set nopaste afterward. Better yet, using "+p to paste from the clipboard register bypasses this problem completely.

Edit: just noticed this is on WSL; the clipboard register doesn't work there, yet, as far as I know.

@drew-viles
Copy link
Author

Sorry for the delay in getting back.

Yeah I've been trough the whole set paste stuff as I'm familiar with vim itself.
You're right though, it seems to be related to the WSL clipboard register. If this is something coming up then I'll leave it be. just seemed strange that sometimes copy and paste works without fail then other, seemingly random times like this, it just doesn't.

@mcornella
Copy link

The same has been happening to me for as long as I can remember. Using CTRL+SHIFT+C copies into a single line, while copying with right-click copies the line-breaks correctly.

This is copied with CTRL+SHIFT+C:

echo -ne '\e[1;33m'                                                                                                cat <<-EOF                                                                                                                      [oh-my-zsh] WARNING: The 'transfer' plugin is deprecated and will be removed after                                      [oh-my-zsh] transfer.sh shuts down on November 30th. We suggest you stop using the                                      [oh-my-zsh] plugin and find an alternative file hosting service.                                                EOF                                                                                                                     echo -ne '\e[0m'

This is copied with right-click:

echo -ne '\e[1;33m'
cat <<-EOF
        [oh-my-zsh] WARNING: The 'transfer' plugin is deprecated and will be removed after
        [oh-my-zsh] transfer.sh shuts down on November 30th. We suggest you stop using the
        [oh-my-zsh] plugin and find an alternative file hosting service.
EOF
echo -ne '\e[0m'

The difference I think is that with CTRL+SHIFT+C the trailing spaces after the ending of a line are copied into the clipboard as if it were a whole line running for as long as the selection ends. Copying with right-click that trailing spaces are gone, and the line-breaks are respected.

Using Microsoft Windows [Versión 10.0.18267.1001]
I'm not running vim nor ssh, just zsh (the same happens running bash). I think this is just a console problem with how CTRL+SHIFT+C is implemented.

@JeremyCCHsu
Copy link

Neither Ctrl+Shift+C nor right-click works in my WSL. Everything I copied from WSL becomes one line when I paste it to a text editor. I tried several configurations in Properties but nothing worked. Strangely, sometimes disabling "Filter clipboard contents on paste" works, but not always.

Another issue that might be related is that tqdm (a progress bar package in Python) doesn't work correctly in WSL.
img

@zadjii-msft
Copy link
Member

I'm fairly certain that Ctrl+Shift+C in conhost has ALWAYS copied text without newlines. I also don't believe we could change that - for every person who doesn't expect C-S-c to copy without newlines, there's another person out there who will complain if we fix it, asking "why doesn't Ctrl+Shift+C copy without newlines anymore?"

@JeremyCCHsu I believe that tqdm issue is unrelated, could you file a new issue to track that?

@zadjii-msft zadjii-msft added Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason. Product-Conhost For issues in the Console codebase Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons. and removed Resolution-Won't-Fix We're just really obstinate about this. There's probably a good reason. labels Nov 9, 2018
@JeremyCCHsu
Copy link

Thanks for clarification. I actually found out that:

  1. If I copy with right-click, the pasted content will be in multiple lines, but
  2. if I copy with Shift + right-click, the context will be in a single line.

I didn't notice this behavioral difference (with or without Shift).

@mcornella
Copy link

for every person who doesn't expect C-S-c to copy without newlines, there's another person out there who will complain if we fix it

I think that's a cop-out. I can't think of any reason why you'd want to copy multiple lines into a single line. I think copying from ctrl+shift+c should exhibit the same behavior as with right-clicking. That's just what makes intuitive sense. And I can't think of any terminal emulator that copies multiline text into a single line.

@samuliasmala
Copy link

Maybe obvious for many but I just realized that you can use CTRL+C to copy the line-breaks correctly while CTRL+SHIFT+C copies into a single line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product-Conhost For issues in the Console codebase Resolution-By-Design It's supposed to be this way. Sometimes for compatibility reasons.
Projects
None yet
Development

No branches or pull requests

6 participants