monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

Should be able to select and copy deleted code

Open StJohn3D opened this issue 7 years ago • 20 comments

When viewing a diff, it is often useful to be able to select and copy portions of recently deleted code. This is allowed in split view and I'm hoping it being disabled in inline view is a simple bug. If it was intended, then we should have an option to enable it.

monaco-editor version: 0.14.3 Browser: Any OS: Any Example: https://microsoft.github.io/monaco-editor/playground.html#creating-the-diffeditor-inline-diff-example

StJohn3D avatar Aug 28 '18 19:08 StJohn3D

+1

VagyokC4 avatar Jun 04 '19 22:06 VagyokC4

I am also here to say that this feature would be of great help to have.

LucienMP avatar Jul 10 '19 15:07 LucienMP

Any news regarding this? It's the second most liked "feature-request" (without it being labeled as it)

ruant avatar Sep 04 '19 08:09 ruant

It is really anoying to not to have this feature. +1

Hadatko avatar Oct 21 '19 15:10 Hadatko

I also came here after finding this: https://developercommunity.visualstudio.com/content/problem/416355/removed-text-is-not-selectable-in-inline-diff-mode.html

I really hope this would be fixed, as it is a huge annoyance.

walliski avatar Nov 12 '19 09:11 walliski

Thank you @alexdima 🎉

StJohn3D avatar Dec 12 '19 19:12 StJohn3D

Also hoping to see this fixed/implemented soon. I've never seen a text editor that doesn't let you select certain text. Really threw me for a loop.

coredumperror avatar Feb 06 '20 18:02 coredumperror

Never knew how much I was taking being able to copy to paste for granted...

TasikBeyond avatar Feb 12 '20 16:02 TasikBeyond

It looks like there are two issues with this. The editor intentionally skips over selecting view zones, which is what the original text is inside. Even if you bypass the skipping of view zones, it looks like the diff editor only takes into account the line numbers from the modified model.

  1. Go to the playground inline diff
  2. Add this line at the end of the existing javascript setTimeout(() => diffEditor.setPosition({lineNumber: 3, column: 4}), 2500);
  3. Click Run
  4. As soon as the editor loads and before the timeout expires, click anywhere in the created diffEditor
  5. Once the timeout expires, you will see the position move to line 3 of the original model.

nrayburn-tech avatar Feb 16 '20 18:02 nrayburn-tech

I found this issue in the vscode repo, which is the same problem. Vscode added buttons that allowed copying the text, example. While I don't like this as a final solution, I think the monaco editor can at least be on the same page as vscode.

@alexdima I would be willing to give this a try. It looks like the issue starts with the StandaloneDiffEditor being constructed without a clipboard service.

nrayburn-tech avatar Feb 17 '20 04:02 nrayburn-tech

I recently requested this feature in GitKraken. They pointed me to this request as they use this editor within GitKraken.

Please consider implementing it!

davejcurry avatar Jun 22 '20 21:06 davejcurry

+1 from GitKraken.

gustavocalheiros avatar Jul 06 '20 15:07 gustavocalheiros

+1 from GitKraken

arthur798 avatar Aug 11 '20 21:08 arthur798

I've complained about this in ADO which also uses Monaco and they referred me here. Adding yet another voice to this request!

dalemyers avatar Sep 02 '20 10:09 dalemyers

I would also like to have this feature in GitKraken. Thanks for considering it!

FelixLisczyk avatar Sep 02 '20 17:09 FelixLisczyk

+1 from GitKraken

MeteC avatar Sep 19 '20 08:09 MeteC

Looks like it's getting closer guys.

  1. Head over to the demo page: https://microsoft.github.io/monaco-editor/index.html
  2. Scroll down to Diff Editor and check the box Inline diff.
  • Then scroll down to where there is line changes, and right click, you're now able to copy single lines at least.
  • And if you scroll even further down, to the pure deletion section, you get the option to copy the entire section or the current line.

Not sure if this is connected to the @nrayburn-tech change adding a clipboardservice (https://github.com/microsoft/vscode/pull/90846), but looks like it. 🥳
Hopefully we can get the "copy section" where there is line changes as well soon :)

How does line changes act compared to pure deletion? Can't be that different? 🤞

ruant avatar Sep 22 '20 08:09 ruant

+1

qiangmao avatar Mar 25 '21 15:03 qiangmao

Five years later, this is still an issue. Is this behaviour intended ? If not, can we expect it to change in the future ? Thanks

paulglx avatar Dec 17 '23 15:12 paulglx

I think, you are free to creare PR ;)

Hadatko avatar Dec 17 '23 16:12 Hadatko