microsoft / monaco-editor

A browser based code editor
https://microsoft.github.io/monaco-editor/
MIT License
40.25k stars 3.59k forks source link

Should be able to select and copy deleted code #1035

Open StJohn3D opened 6 years ago

StJohn3D commented 6 years ago

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

VagyokC4 commented 5 years ago

+1

LucienMP commented 5 years ago

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

ruant commented 5 years ago

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

Hadatko commented 5 years ago

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

walliski commented 4 years ago

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.

StJohn3D commented 4 years ago

Thank you @alexdima 🎉

coredumperror commented 4 years ago

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.

TasikBeyond commented 4 years ago

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

nrayburn-tech commented 4 years ago

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 commented 4 years ago

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.

davejcurry commented 4 years ago

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

Please consider implementing it!

gustavocalheiros commented 4 years ago

+1 from GitKraken.

arthur798 commented 4 years ago

+1 from GitKraken

dalemyers commented 4 years ago

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

FelixLisczyk commented 4 years ago

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

MeteC commented 4 years ago

+1 from GitKraken

ruant commented 4 years ago

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? 🤞

qiangmao commented 3 years ago

+1

paulglx commented 10 months ago

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

Hadatko commented 10 months ago

I think, you are free to creare PR ;)