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

VS Code theme style is added to text copied to the clipboard as rich text instead of plain text. #67702

Closed
bermlee opened this issue Feb 1, 2019 · 13 comments
Labels
editor-clipboard Editor clipboard issues feature-request Request for new features or functionality

Comments

@bermlee
Copy link

bermlee commented Feb 1, 2019

Issue Type: Bug

  1. Copy text, paste into Word or GMail or any other rich-text editor.
  2. Result: White on Black text in the font of VS Code's interface. (Or whatever the current theme is)

Expected: plain text pasted only.

Also opened before by @alex-jitbit
#63154
Reported as a "feature" that can be turned off by @rebornix, and indeed it can be turned off with "Editor: Copy With Syntax Highlighting"

HOWEVER, I believe that this should NOT be default behavior, and at the least believe that the "text background" should NOT be copied along with it, and the un-highlighted text be turned to black when copied as rich-text in the clipboard.

Platform: Windows

VS Code version: Code 1.30.2 (61122f8, 2019-01-07T22:54:13.295Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-6650U CPU @ 2.20GHz (4 x 2208)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.93GB (6.61GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (1)
Extension Author (truncated) Version
vscode-autohotkey sle 0.2.2
@vscodebot vscodebot bot added the editor-clipboard Editor clipboard issues label Feb 1, 2019
@ryanoshea
Copy link

Most programs copy and paste rich text where possible, and some of the nice ones (Chrome, Office) offer a paste-as-plain-text functionality on the assumption that what's in the clipboard has both rich and non-rich versions. I think the current setting is a sensible default.

@rebornix rebornix added the *question Issue represents a question, should be posted to StackOverflow (VS Code) label Aug 6, 2019
@vscodebot vscodebot bot closed this as completed Aug 6, 2019
@microsoft microsoft deleted a comment from vscodebot bot Aug 6, 2019
@rebornix rebornix added feature-request Request for new features or functionality and removed *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Aug 6, 2019
@rebornix rebornix reopened this Aug 6, 2019
@moxley
Copy link

moxley commented Sep 19, 2019

Most programs copy and paste rich text where possible, and some of the nice ones (Chrome, Office) offer a paste-as-plain-text functionality on the assumption that what's in the clipboard has both rich and non-rich versions. I think the current setting is a sensible default.

Most programs are not code editors.

I can think of many reasons how this "feature" is a bug, but no reasons why this is useful.

VS Code Version: 1.38.1
OS: MacOS 10.14.6

@mhkeller
Copy link

I also think the default should be to copy as plain text since that is my most common use case – I'm pasting into chat, email, Google Doc and I don't want my syntax theme in those environments. I can't think of a common use case where you want the opposite.

@Lemmingh
Copy link
Contributor

Lemmingh commented Oct 4, 2021

Take a look at:

"Copy with syntax highlighting" got hundreds of thumbs up in 2016. (That issue was locked in 2017.)

But your "Copy as plain text" only gets three now. (It's three years since 2019.)

Which side wins? "Copy with syntax highlighting" should be the default. Indeed, VS Code writes both plain text and HTML into clipboard, and it's the target application that decides which format to paste. (#57577 (comment))

@alex-jitbit
Copy link

alex-jitbit commented Oct 4, 2021

@Lemmingh thumbs-driven development, huh...

I guess most people who don't need the black background when pasting stuff to Gmail, are not familiar with github and issue-trackers.

Also, the issue you linked says "add ability", not "make it default"

@rebornix rebornix removed their assignment Oct 11, 2021
@hediet hediet added this to the Backlog Candidates milestone Oct 25, 2021
@bermlee
Copy link
Author

bermlee commented Oct 25, 2021

Thank you for the discussion, and consideration for inclusion into the backlog.

I can see why lots of people would want to create presentations, chat or write emails with syntax highlighting themed exactly as they see it on their screen, and I get the reason why this got voted in as a standard feature for VS Code.

As the primary use case for VS Code is for developers writing and discussing code, copying over syntax highlighting is helpful, and appropriate.

The default behavior of copying the entire display theme as-is, including the background seems inappropriate when copying code for even on-screen consumption that have the opposite light (or dark) background, and worse for more longer-term documentation or instruction to be viewed on a printed (or e-book) page.

The default behavior is made more jarring when working with Markdown or Plain Text files across other notetaking apps that respect rich-text formatting. I know this can be overridden at paste time by using Ctrl-Shift-V in SOME apps, but in Microsoft Word, it's an extra menu step to select Keep Text Only.

My request is not that the feature be removed, but to be made more refined. Formatting in an IDE is applied to the content by the environment, and are not applied properties to the content itself by the author. As the expectation for most rich-text formatting is to paste into documents with dark-text on a white background (to make situations involving printing to paper less complicated), I believe VS Code's designers could envision a default behavior that applies a default syntax highlighting color scheme WITHOUT an included background color that would work optimally for light backgrounds, but also be more than legible if pasted into a presentation with a dark background.

Thank you for all your hard work.

@alex-jitbit
Copy link

One more point: this is not the default behavior in the "full" Visual Studio (non-code). The behavior should be consistent across products.

@bermlee
Copy link
Author

bermlee commented Nov 10, 2021

what are some things we could do to make this more visible, aside from tweeting about it?

@Lemmingh
Copy link
Contributor

As far as I'm aware, this issue is eventually about the default value of the editor.copyWithSyntaxHighlighting setting (#54155), and can become an argument about preference.


thumbs-driven development

Let the data speak. This is reasonable under limited resource constraints. VS Code's wiki also conveys such idea.

Given that VS Code can even encourage users to join GitHub, I think the thumbs here should be sufficient.

I searched for similar issues. It appears roughly 100 for false and 200 for true, so the default value should still be true (With syntax highlighting).


The default behavior of copying the entire display theme as-is, including the background seems inappropriate when copying code for even on-screen consumption that have the opposite light (or dark) background

This has been discussed many times:


Well, let's take a glance at how clipboard transfers data again.

A clipboard can hold multiple objects of different formats (called "MIME type" on web platforms). When writing to the clipboard (copy), an application is expected to put the data in many possible types. When reading from the clipboard (paste), an application selects the one it prefers.

When copying in VS Code, a few objects are written into the clipboard, usually plain text (text/plain) and custom metadata (vscode-editor-data). HTML (text/html) is also appended when "Copy With Syntax Highlighting" is enabled or requested.


Here are a few guidelines about interacting with the clipboard.

Microsoft (Win32):

A window can place more than one clipboard object on the clipboard, each representing the same information in a different clipboard format. When placing information on the clipboard, the window should provide data in as many formats as possible.

Microsoft (Xamarin.Mac):

To maximize the potential for sharing, the pasteboard can hold multiple representations of a given item (using a standard set of common data types), this allow the consuming app to pick the version that is best suited for its needs.

Apple (UIKit):

You can provide flexibility for data sharing by providing multiple representation types for a pasteboard item during a Copy or Cut operation. Various contexts within your app or other apps can then make use of an appropriate representation type.

Apple (AppKit):

You can create one or more pasteboard items, set data or data providers for types, and write to them pasteboard.

You can retrieve pasteboard items from the pasteboard then read the data for types you’re interested in.


the "full" Visual Studio

I'm afraid this is a misnomer. Visual Studio and Visual Studio Code are totally different products, just like Java and JavaScript are totally different languages. I'd suggest avoiding expressions like "full / slim Visual Studio".


Here are Visual Studio's options.

Visual Studio 2019 - Options


in Microsoft Word, it's an extra menu step to select Keep Text Only

You can change the default in Options > Advanced.

Word for Microsoft 365 - Options

@alex-jitbit
Copy link

alex-jitbit commented Jan 2, 2022

@Lemmingh

Visual Studio and Visual Studio Code are totally different products, just like Java and JavaScript are totally different languages. I'd suggest avoiding expressions like "full / slim Visual Studio".

"Java and JavaScript" is a fine example of poor naming and a branding disaster.

Just like "Visual Studio and Visual Studio Code" is poor naming and a branding disaster. And it's a pain to google for things, because you get mixed results.

So yeah, most people call it "full" Visual Studio.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-clipboard Editor clipboard issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

9 participants