当刚打开文件时,VSCode扩展启动功能



我想打开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不是通过语言开关激活的,而是通过命令调色板、键绑定或菜单项选择激活的。

最新更新