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 pasting from latest VS Code adds invisible characters #80825
Comments
@bfelbo VS Code writes to the clipboard two distinct contents:
An application, when pasting to it, can choose which content type to read from the clipboard. A code editor typically reads the plain text content. That is what VS Code does when you paste into it. A rich editor (like Word) typically reads the HTML content. I think the Postico editor might have an issue where it reads the HTML content from clipboard. How do things look like when you copy from VS Code and paste to another VS Code window? |
@bfelbo Have you tried disabling all extensions? |
I had the same problem of pasting code from Code behaving strangely in other programs. I was able to track back that in the pasted clipboard spaces in code are substituted by the sequence c2a0 (that's utf-8 for the non-breaking space character). This breaks some program, while others seems to convert to spaces (textmate). To reproduce: copy some code from Visual Studio Code; paste it in Postico (I had the same problem with other editors, may be Xcode itself, but this is what I'm using now); copy from Postico; paste in a file (or in textmate); read the file with an hex-editor to find the nbsp characters. This could be a bug in Postico (as you said above) but I just tried to copy html from safari and paste it in Postico and no nbsp appeared. Hope this helps you narrow down the problem. I'm on latest stable macOS. Code in itself reports: |
For the records, this is considered a bug in Postico. There is a workaround in the issue lined above, that's using a VSCode extension that does a copy without formatting: https://marketplace.visualstudio.com/items?itemName=bmaupin.copy-without-formatting |
Thank you for following through. I think this is a bug specific to Postico, where they read the HTML value in the clipboard. |
Postico developer here. This issue is not unique to Postico. It also happens with Text Edit. It also happens with Mail. If people copy-paste text from VS Code to Mail, they'll end up with the wrong type of spaces. It happens with every app that uses a standard Cocoa In Postico I found a workaround. If I change the text field type to Anyway, the problem is that AppKit prefers HTML to plain text when pasting into a rich text field. I think that Apple's assumption was that plain text and styled text would be identical except for attributes. In my opinion VS Code should do one of the following things
|
@alexandrudima can we open this issue again? |
A short follow up on this issue:
So if you copy text from VS Code to Mail, you'll end up with the wrong spaces. I still think the VS code developers should fix this. |
@jakob Thank you for the nice write-up. I agree, we should improve what we write to the html clipboard such that the text content of those dom nodes still represents the source text... I think I personally always considered the HTML clipboard as a "painting canvas", i.e. it doesn't matter what kind of spaces we'd write in there given that code would most likely be pasted in a rich email or a rich document and be used for "viewing" only... But the text could then be further copied out from the email/rich document and pasted back into another editor... |
Verification steps:
Compare |
fyi @rebornix |
I have a problem like that, but i am have an aditional case, when i am copying from vs-code to wordpress editor in browser this code: i am having output like that: VS-Code: |
@asverq Your issue is IMHO not related to the original issue. It appears that in your case, when you paste in wordpress, the text is changed and all the AFAIK we have no such replacement implemented in our code base, so I would think it is an issue with wordpress. If you consider this to be an issue with VS Code, please open a new issue. |
Steps to Reproduce:
I reproduced these steps, but copying from Atom instead of VS Code, and everything worked fine. Similarly, everything works fine in an older version of VS Code (1.34).
Does this issue occur when all extensions are disabled? Yes
The text was updated successfully, but these errors were encountered: