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

Add setting to keep tab characters in HTML clipboard #134588

Open
erkkifromdeepforest opened this issue Oct 7, 2021 · 7 comments
Open

Add setting to keep tab characters in HTML clipboard #134588

erkkifromdeepforest opened this issue Oct 7, 2021 · 7 comments
Assignees
Labels
editor-clipboard Editor clipboard issues feature-request Request for new features or functionality
Milestone

Comments

@erkkifromdeepforest
Copy link

We have written the needed data into your clipboard because it was too large to send. Please paste.

Issue Type: Bug

I select a portion of my text in VS Code, send a copy to clipboard (ctrl-c), move mouse cursor to a Word document, and try to paste the text with ctrl-V. The text appears on Word, but the tab characters are converted to spaces.
Then I try another route: VS Code -> TextPad -> Word, and here the tabs are copied correctly. - So one of the Microsoft Apps fails in this copy - paste operation: Word or Code. Please make a correction!

VS Code version: Code 1.60.2 (7f6ab54, 2021-09-22T12:00:31.514Z)
OS version: Windows_NT x64 10.0.19043
Restricted Mode: No

System Info
Item Value
CPUs Intel(R) Core(TM) i7-3635QM CPU @ 2.40GHz (8 x 2395)
GPU Status 2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
skia_renderer: enabled_on
video_decode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
Load (avg) undefined
Memory (System) 15.89GB (12.20GB free)
Process Argv --crash-reporter-id 45a27e0b-c086-47c7-bb82-a3bc76a31454
Screen Reader no
VM 0%
Extensions: none
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
pythonvspyt602:30300191
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyt639:30300192
pythontb:30283811
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
pythonvsuse255:30340121
vscod805cf:30301675
pythonvspyt200:30340761
binariesv615:30325510
vsccppwt:30378364
pythonvssor306:30344512
bridge0708:30335490
pygetstartedt2:30371810
dockerwalkthru:30377721
bridge0723:30353136
pythonrunftest32:30373476
pythonf5test824:30373475
javagetstartedt:30364666
pythonvspyt187:30373474
pydsgst2:30361792
vsqsis400:30374798
vsaa593:30376534

@alexdima alexdima added editor-clipboard Editor clipboard issues windows VS Code on Windows issues labels Oct 8, 2021
@alexdima
Copy link
Member

alexdima commented Oct 8, 2021

@erkkifromdeepforest We have just shipped a change with 1.61.0 in this area (#131922). Could you please update to 1.61.0 and check if this still reproduces for you?

Could you please also include here the text that you are using (I would like to look at it to see if it uses tabs or spaces for indentation) and include screenshots of how the pasted text looks in Word?

@alexdima alexdima added the info-needed Issue requires more information from poster label Oct 8, 2021
@erkkifromdeepforest
Copy link
Author

erkkifromdeepforest commented Oct 8, 2021 via email

@alexdima
Copy link
Member

Thank you @erkkifromdeepforest for the extra information. The screenshots did not come through because they don't work over email. They would work if you would upload them manually at #134588

Here is what is going on:

  • when you press cmd+c, vscode writes to the clipboard in two different formats: plain text and html
    • the source code you have selected is written to the plain text as is
    • the source code you have selected is written also as HTML (to add syntax colors) and in there the tabs are replaced with the corresponding number of spaces in order to align things
  • when pasting in BBEdit, it looks like BBEdit reads the plain text data from the clipboard.
  • when pasting in Word, it looks like Word reads the HTML data from the clipboard.

I think you would want a way to configure vscode to write tabs as they are to the HTML clipboard.

@alexdima alexdima changed the title Copy-paste from Code to Word Add setting to keep tab characters in HTML clipboard Oct 11, 2021
@alexdima alexdima added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster windows VS Code on Windows issues labels Oct 11, 2021
@erkkifromdeepforest
Copy link
Author

erkkifromdeepforest commented Oct 14, 2021 via email

@erkkifromdeepforest
Copy link
Author

Here the files which I have earlier tried to send in email,

  • Code to Word.png Text copied using clipboard (Mac)
  • Kohdehaku.xaml.cs The text in the preceding image
  • Xcode to Word.png Text copied (Mac) from Xcode using clipboard
  • Visual Studio to Word.PNG Text copied (Windows) from Visual Studio using clipboard
    Regards, Erkki Ahola
    Code to Word
    Kohdehaku.xaml.cs.zip
    Xcode to Word
    Visual Studio to Word

l

@alexdima
Copy link
Member

As a reference, here is what xcode creates for the code:

//
//  ContentView.swift
//  Shared
//
//  Created by Alex on 10/14/21.
//

import SwiftUI

struct ContentView: View {
	var body: some View {
		Text("Hello, world!")
			.padding()
	}
}

struct ContentView_Previews: PreviewProvider {
	static var previews: some View {
		ContentView()
	}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="2022.6">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #5d6c79; background-color: #ffffff}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #000000; color: rgba(0, 0, 0, 0.85); background-color: #ffffff}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #0b4f79; background-color: #ffffff}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #c41a16; background-color: #ffffff}
p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo; color: #9b2393; background-color: #ffffff}
span.s1 {color: #9b2393}
span.s2 {color: rgba(0, 0, 0, 0.85)}
span.s3 {color: #0f68a0}
span.s4 {color: #0b4f79}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1">//</p>
<p class="p1">//<span class="Apple-converted-space">&nbsp; </span>ContentView.swift</p>
<p class="p1">//<span class="Apple-converted-space">&nbsp; </span>Shared</p>
<p class="p1">//</p>
<p class="p1">//<span class="Apple-converted-space">&nbsp; </span>Created by Alex on 10/14/21.</p>
<p class="p1">//</p>
<p class="p2"><br></p>
<p class="p3"><span class="s1"><b>import</b></span> SwiftUI</p>
<p class="p2"><br></p>
<p class="p4"><span class="s1"><b>struct</b></span><span class="s2"> </span>ContentView<span class="s2">: View {</span></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="s1"><b>var</b></span> <span class="s3">body</span>: <span class="s1"><b>some</b></span> View {</p>
<p class="p5"><span class="s2"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>Text(</span>"Hello, world!"<span class="s2">)</span></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>.padding()</p>
<p class="p3"><span class="Apple-tab-span">	</span>}</p>
<p class="p3">}</p>
<p class="p2"><br></p>
<p class="p3"><span class="s1"><b>struct</b></span> <span class="s4">ContentView_Previews</span>: PreviewProvider {</p>
<p class="p6"><span class="s2"><span class="Apple-tab-span">	</span></span><b>static</b><span class="s2"> </span><b>var</b><span class="s2"> </span><span class="s3">previews</span><span class="s2">: </span><b>some</b><span class="s2"> View {</span></p>
<p class="p3"><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span>ContentView()</p>
<p class="p3"><span class="Apple-tab-span">	</span>}</p>
<p class="p3">}</p>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-clipboard Editor clipboard issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants
@alexdima @erkkifromdeepforest and others