microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.18k stars 29.29k forks source link

macOS: Copying text to clipboard does not preserve tabs #31829

Open sathomas opened 7 years ago

sathomas commented 7 years ago

This might be an Electron problem rather than VS Code, but copying text to the clipboard does not preserve tabs. Instead, it converts the tabs to an appropriate number of non-breaking space characters.

Here is settings.json:

{
    "editor.fontFamily": "'SFMono Light', Hack, Menlo, Monaco, 'Courier New', monospace",
    "editor.minimap.enabled": false,
    "editor.fontSize": 15,
    "editor.renderIndentGuides": true,
    "terminal.integrated.fontSize": 14,
    "editor.insertSpaces": false,
    "editor.autoIndent": false,
    "editor.detectIndentation": false
}
Extension Author (truncated) Version
EditorConfig Edi 0.9.4
angular1-code-snippets-johnpapastyle lpe 0.1.0
guides spy 0.8.4

Steps to Reproduce:

  1. Insert text with tabs
  2. Copy text to clipboard
  3. Clipboard contents have non-breaking spaces instead of tabs

Reproduces without extensions: Yes

sathomas commented 7 years ago

As a point of reference, atom.io does not have this problem, so if it's Electron-releated there is a way to avoid it.

humphd commented 6 years ago

Possibly related https://github.com/Microsoft/vscode/issues/31889

paflopes commented 4 years ago

I've been through a similar problem recently. After updating vscode to the 1.42.1 version the code copied from vscode wasn't keeping indentation anywhere (Libreoffice, google docs, WPS Office).

Looking into the problem I saw the html generated by the 1.42.1 version is generating regular spaces instead of non-breaking spaces inside the <span> tags, it seems that this strategy doesn't play well with the software I mentioned above.

So for now I rolled back to the version 1.39.2 since this is a feature I rely on for generating documentation for my clients.

More details are below:

OS: Ubuntu 19.10 It's reproducible without extexsions

HTML Generated by VS Code 1.39.2

<meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="color: #333333;background-color: #fdf6e3;font-family: '"Jetbrains Mono",Iosevka', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback';font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #268bd2;">servers</span><span style="color: #333333;">:</span></div><div><span style="color: #333333;">&nbsp;&nbsp;-&nbsp;</span><span style="color: #268bd2;">description</span><span style="color: #333333;">:&nbsp;</span><span style="color: #2aa198;">Server1</span></div><div><span style="color: #333333;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #268bd2;">url</span><span style="color: #333333;">:&nbsp;</span><span style="color: #2aa198;">http://api.example.com/v1/servers</span></div><br></div>

HTML Generated by VS Code 1.42.1

<meta http-equiv="content-type" content="text/html; charset=utf-8"><div style="color: #333333;background-color: #fdf6e3;font-family: '"Jetbrains Mono",Iosevka', 'Droid Sans Mono', 'monospace', monospace, 'Droid Sans Fallback';font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"><div><span style="color: #268bd2;">servers</span><span style="color: #333333;">:</span></div><div><span style="color: #333333;">  - </span><span style="color: #268bd2;">description</span><span style="color: #333333;">: </span><span style="color: #2aa198;">Server1</span></div><div><span style="color: #333333;">    </span><span style="color: #268bd2;">url</span><span style="color: #333333;">: </span><span style="color: #2aa198;">http://api.example.com/v1/servers</span></div><br></div>

[EDIT]

I just saw the change that makes it stop working:

b6138b95268aea0768f77ae8e4eacbcc0621bf07

and it closes the issue

80825

It'd be nice to have this back to work on Ubuntu, but I really don't know how to conciliate both issues.