I want to open pubspec.yaml
file and kick some function VSCode extenision. but nothing happned. Why can't I?
"activationEvents": [
"onLanguage:yml"
],
"main": "./dist/extension.js",
"contributes": {
"views": {
"explorer": [
{
"id": "mrgao_luckys",
"name": "pubspec.yaml"
}
]
},
"commands": [
{
"command": "flutter-pub-version-checker.helloWorld",
"title": "Hello World"
}
]
},
"activationEvents": [
"onLanguage:yml"
],
This activation event is emitted and interested extensions will be activated whenever a file that resolves to a certain language gets opened. [from onLanguage api]
So when you open a yml
file the extension is activated, not any particular command. The rest of your package.json
really has nothing to do with this onLanguage:yml
activation.
You can see this if you simply have this in your extension.js
:
async function activate(context) {
someFunction(); // this function will be run whenever you switch to a `yml` file.
// this will be run too, but it just registers the command, does not trigger it
// the command is triggered in other ways
vscode.commands.registerCommand('flutter-pub-version-checker.helloWorld'.....{} )
}
Your command flutter-pub-version-checker.helloWorld
is not activated by the language switch - it is activated through the command palette or a keybinding or a menu item selection.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.