我想打开pubspec.yaml
文件并启动一些函数VSCode扩展。但什么也没发生。为什么我不能?
"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"
],
此激活事件已发出,感兴趣的扩展将每当解析为某种语言的文件打开。[来自onLanguage api]
因此,当您打开yml
文件时,扩展名将被激活,而不是任何特定的命令。您的package.json
的其余部分实际上与此onLanguage:yml
激活无关。
如果你在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'.....{} )
}
您的命令flutter-pub-version-checker.helloWorld
不是通过语言开关激活的,而是通过命令调色板、键绑定或菜单项选择激活的。