Copy selection for deleted chunk in inline diff#267991
Merged
hediet merged 6 commits intomicrosoft:mainfrom Oct 15, 2025
Merged
Copy selection for deleted chunk in inline diff#267991hediet merged 6 commits intomicrosoft:mainfrom
hediet merged 6 commits intomicrosoft:mainfrom
Conversation
(Attempt to) Fix microsoft#8226
Member
Contributor
Author
hediet
approved these changes
Oct 15, 2025
Member
There was a problem hiding this comment.
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.
Tyriar
approved these changes
Oct 15, 2025
Comment on lines
+430
to
+439
| .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; | ||
| } |
Member
There was a problem hiding this comment.
@hediet might want to follow up with consistent selector prefix and/or nesting?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


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!