-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Extension API request: onCopy and onPaste #43718
Comments
Can you specify that? |
I don't know under which circumstances vscode doesn't run commands defined in extensions, sometimes it seems to be random and if I reload the window it starts to work again. One place I've found it to be very reproducible is when you open very large documents. Even if you do For example, download and uncompress this file: open it in vscode and none of the hotkeys that I have hooked up to extensions work. With copy with imports installed I cannot copy/paste with this file, and with Cursor move installed, |
Yeah, that's the designed behaviour because for performance reasons we don't let extensions know about very large documents.
When you say that do you mean nothing happens or that the extension behaviour doesn't happen? |
I've defined a hotkey to call my extension's version of copy/paste when you do So that makes my extension sometimes completely break copy/paste. This is a very poor experience and I'd like some kind of work around. The ideas I can think of are either:
|
Ok, when dealing with large documents (>50MB) that's a known limitation. Are there other scenarios you know when your command should run but doesn't? |
It happens periodically, it seems to be when the vscode process is using high CPU. However, I haven't been able to consistently reproduce it. Copy/paste will break, I'll reload vscode and it will work again. |
Likely when an extension goes crazy and taking away all compute from other extensions. When that happens, please profile running extensions. Do so by pressing F1 > Running Extensions > Hit the Red button: https://github.com/Microsoft/vscode/wiki/Performance-Issues#profile-the-running-extensions |
Right, so I can do that to figure out which my the extensions I am running may be using the compute power. But this isn't a reasonable workaround for my extension to perform properly for other people. There ought to be a way for my extension to have a degraded condition where it still allows basic editing abilities (copy/paste) even when other extensions are going crazy. Thoughts? |
Yeah, the unfortunate reality of JavaScript. What we can do is detect that a command wanted to run but that the request never made it over the wire. We can then show a message and our assumption is that such a case is rare. What we cannot do is run another command because it is hard for us to figure-out what other command is appropriate |
So I'm proposing a couple of options that would make my use case work:
Do you think either of these would work? |
I requested the same thing in #30066. My analysis server can bring imports with copy/pastes but currently I can't participate in the actions :( Overriding hotkeys doesn't seem like a good solution since users can change them. |
Option №1 makes more sense, I would want it too! I also made an extension that overrides the native copy and cut commands. That means I can not use any other extension that is intended to work on copy and cut commands execution. Attaching a handler to native command instead of overriding it would solve the problem. |
/duplicate of #30066 |
Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines. Happy Coding! |
I've created an extension which automatically brings imports when you copy and paste between files. However, in order to do this I had to override the default cut/copy/paste hotkeys.
In each of my commands I call the default
editor.action.clipboard*Action
and then do the things specific to my plugin. Here's the relevant snippet:However, sometimes vscode doesn't call extension commands, which makes my extension break copy/paste.
I would like to either be able respond to the built in commands rather than overriding the hotkeys, or allow the default hotkey to run if vscode decides to skip my extension defined command.
The text was updated successfully, but these errors were encountered: