-
Notifications
You must be signed in to change notification settings - Fork 36.7k
Copy selection for deleted chunk in inline diff #267991
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
Conversation
(Attempt to) Fix microsoft#8226
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I'm not sure that we should show the context menu automatically, but its still better than before, so I'm happy to get this change in.
Also I think it would be great if if could copy the text of multiple deleted chunks at once, ideally including the unchanged lines in between.
| .monaco-editor .line-delete-selectable { | ||
| user-select: text !important; | ||
| -webkit-user-select: text !important; | ||
| z-index: 1 !important; | ||
| } | ||
|
|
||
| .line-delete-selectable .view-line { | ||
| user-select: text !important; | ||
| -webkit-user-select: text !important; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hediet might want to follow up with consistent selector prefix and/or nesting?


An attempt to fix #8226
Hi @hediet , can I interest you with (yet another) PR for #8226, a.k.a. inline diff deleted chunk copy selection? :)
The main idea is to calculate the exact line and column for the start & end of the selection in a view zone, and extract the corresponding code chunk using the text model API.
Demo:

This works with both the menu item, and the browser 'copy' event (Ctrl/Cmd+C).
I have put the setup in a reusable method in a separate file, following the example of renderLines.ts
Due to the view zone, there are some hackery involved to get those line and column numbers right (the line number extraction is the same as that from the inlineDiffDeletedCodeMargin.ts). Let me know if you see any issues, or if you prefer to solve it in a different way.
Thanks!