-
Notifications
You must be signed in to change notification settings - Fork 39k
Getting "command not found" error in my extension despite having the onCommand activation event #48605
Description
- VSCode Version: 1.22.2
- OS Version: Win10 64 bit
Steps to Reproduce:
- Start VSCode with this extension (either by installing it from the marketplace, or with the debugger) with the Explorer view being hidden.
- Create a new file, type some text and select it.
- Try to save it as a Code Fragment with the extension by opening the Command Palette and executing the "Save selection as Code Fragment" command
It won't work, the following error will be displayed: command 'codeFragments.saveSelectedCodeFragment' not found.
In my extension I have the following activation events:
"activationEvents": [
"onCommand:saveSelectedCodeFragment",
"onView:codeFragments"
],
I expect the first one to prevent this problem, so that it should make sure that the extension is activated when that command is executed.
With some experimentation I noticed that if I also add "*" as an activation event, then the issue goes away. But is that the proper way? I don't necessarily want to load my extension on startup, it'd be enough to be activated the first time this command is executed.
Is this the expected behavior, or a bug?
In either case, I think the documentation should be clarified, because it's unclear whether the onCommand event should be enough in this case or not.