Skip to content

Conversation

@Mingpan
Copy link
Contributor

@Mingpan Mingpan commented Sep 23, 2025

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:
copySelectionInlineDelete

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!

@hediet hediet self-requested a review September 24, 2025 18:27
@hediet
Copy link
Member

hediet commented Sep 24, 2025

Hey! Thanks for the PR ;)

I tried it, but the selection is not rendered for me (Windows):

Code_-_OSS_O3WHk4dgHI

Can you look into this? Thanks!

@hediet hediet added this to the September 2025 milestone Sep 24, 2025
@Mingpan
Copy link
Contributor Author

Mingpan commented Sep 24, 2025

Thanks for the quick response!

Could you try if my last commit help with that?

This was actually my original version but then I made the CSS class "dynamic" to avoid things like this:
selection-escape-inline-delete-chunk

But that likely has created some race condition :(

In hindsight, this is probably still better than not showing the selection sometimes... but let me know if you want the above situation ⬆️ fixed as well. I can play with it a bit more.

Edit: perhaps some hover / mousein&out event could be better suited to toggle that CSS class?

Let me know what you think :)

@hediet hediet modified the milestones: September 2025, October 2025 Sep 30, 2025
Copy link
Member

@hediet hediet left a 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.

@hediet hediet enabled auto-merge (squash) October 15, 2025 10:35
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;
}
Copy link
Member

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?

@hediet hediet merged commit 2b00e85 into microsoft:main Oct 15, 2025
17 checks passed
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Dec 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot select text from deleted lines diff view

3 participants