![](/img/trans.png)
[英]How to open a local (inside the extension package) file in a vscode extension
[英]VSCode extension kick function when just open file
我想打開pubspec.yaml
文件並啟動一些 function 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 的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
不會被語言切換激活 - 它是通過命令面板或鍵綁定或菜單項選擇激活的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.