簡體   English   中英

剛剛打開文件時VSCode擴展踢function

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM