Repository: vscode
Issue: Copy-Paste Formatted Code Doesn't Work Properly On Linux (Works On Windows)
Labels: bug,editor-clipboard

- VS Code Version: 1.55.2
- OS Version: Kubuntu 20.04 (Linux)

Steps to Reproduce:

1. Open VS Code 1.55.2 on Linux
2. Open a JavaScript (.js) file
2. Select some code, & Copy
3. Paste to any 'Rich Text' editor (i.e. LibreOffice Writer, AbiWord, WPS Office Writer, or SoftOffice TextMaker).
4. Observe that there is no indentation in the pasted text

Does this issue occur when all extensions are disabled?: Yes

Full Description:

On Windows, I can copy from VS Code & paste it into i.e. MS Word, and it retains all the correct formatting (both coloring/syntax highlighting & indentation). However, on Linux, there doesn't seem to be any combination that works: pasting it anywhere else seems to lose either the coloring or the indentation. Here's a very simple example - source code, as shown in VS Code:

![AUYPJ](https://user-images.githubusercontent.com/1877409/115907256-7d696c80-a41d-11eb-978f-2e20ef54e37f.png)

If I paste it to LibreOffice Writer, WPS Office Writer, SoftOffice TextMaker, or AbiWord, it loses its indentation:

![AUYPJ](https://user-images.githubusercontent.com/1877409/115907331-92460000-a41d-11eb-9ade-89202e8fb9fb.png)

Conversely, if I paste it to MS Word running in VirtualBox, it keeps its indentation but loses its color:

![AUYPJ](https://user-images.githubusercontent.com/1877409/115907374-a2f67600-a41d-11eb-9878-2fa1b22911e2.png)

Here's the raw HTML in the clipboard, as shown by CopyQ (a clipboard utility):

```
<meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="color: #000000;background-color: #ffffff;font-family: 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback';font-weight: normal;font-size: 12px;line-height: 16px;white-space: pre;"><div><span style="color: #0000ff;">import</span><span style="color: #000000;"> React </span><span style="color: #0000ff;">from</span><span style="color: #000000;"> </span><span style="color: #a31515;">"react"</span><span style="color: #000000;">;</span></div><br><div><span style="color: #0000ff;">function</span><span style="color: #000000;"> withTooltip(Component) {</span></div><div><span style="color: #000000;">    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #0000ff;">class</span><span style="color: #000000;"> WithTooltip </span><span style="color: #0000ff;">extends</span><span style="color: #000000;"> React.Component {</span></div><div><span style="color: #000000;">        state = { showTooltip: </span><span style="color: #0000ff;">false</span><span style="color: #000000;"> };</span></div><div><span style="color: #000000;">        render() { </span></div><div><span style="color: #000000;">            </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> (</span></div><div><span style="color: #000000;">                </span><span style="color: #800000;">&lt;div</span><span style="color: #000000;"> </span><span style="color: #800000;">/&gt;</span></div><div><span style="color: #000000;">            );</span></div><div><span style="color: #000000;">        }</span></div><div><span style="color: #000000;">    };</span></div><div><span style="color: #000000;">}</span></div><br><div><span style="color: #0000ff;">export</span><span style="color: #000000;"> </span><span style="color: #0000ff;">default</span><span style="color: #000000;"> withTooltip;</span></div></div>
```

If I reboot to Windows & copy-paste from VS Code 1.55.2 to MS Word (or any other Windows richext editor), the formatting comes out properly.  The html produced on Windows (also obtained via CopyQ) looks completely different to the html produced by VS Code on Linux. Here's the html from Windows:

```
<html>
<body>
<!--StartFragment--><div style="color: #000000;background-color: #ffffff;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 12px;line-height: 16px;white-space: pre;"><div><span style="color: #0000ff;">import</span><span style="color: #000000;">&#160;React&#160;</span><span style="color: #0000ff;">from</span><span style="color: #000000;">&#160;</span><span style="color: #a31515;">"react"</span><span style="color: #000000;">;</span></div><br><div><span style="color: #0000ff;">function</span><span style="color: #000000;">&#160;withTooltip(Component)&#160;{</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&#160;</span><span style="color: #0000ff;">class</span><span style="color: #000000;">&#160;WithTooltip&#160;</span><span style="color: #0000ff;">extends</span><span style="color: #000000;">&#160;React.Component&#160;{</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;state&#160;=&#160;{&#160;showTooltip:&#160;</span><span style="color: #0000ff;">false</span><span style="color: #000000;">&#160;};</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;render()&#160;{&#160;</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #0000ff;">return</span><span style="color: #000000;">&#160;(</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</span><span style="color: #800000;">&lt;div</span><span style="color: #000000;">&#160;</span><span style="color: #800000;">/&gt;</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;);</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</span></div><div><span style="color: #000000;">&#160;&#160;&#160;&#160;};</span></div><div><span style="color: #000000;">}</span></div><br><div><span style="color: #0000ff;">export</span><span style="color: #000000;">&#160;</span><span style="color: #0000ff;">default</span><span style="color: #000000;">&#160;withTooltip;</span></div></div><!--EndFragment-->
</body>
</html>
```

Thus, every time I need to copy formatted code out of VS Code, I find myself having to reboot completely to Windows just to do the copy-paste, as it works fine there, but not on Linux.