简体   繁体   English

刚刚打开文件时VSCode扩展踢function

[英]VSCode extension kick function when just open file

I want to open pubspec.yaml file and kick some function VSCode extenision.我想打开pubspec.yaml文件并启动一些 function VSCode 扩展。 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] [来自onLanguage api]

So when you open a yml file the extension is activated, not any particular command.因此,当您打开yml文件时,会激活扩展名,而不是任何特定命令。 The rest of your package.json really has nothing to do with this onLanguage:yml activation.您的 package.json 的package.json确实与此onLanguage:yml激活无关。

You can see this if you simply have this in your extension.js :如果你只是在你的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.您的命令flutter-pub-version-checker.helloWorld不会被语言切换激活 - 它是通过命令面板或键绑定或菜单项选择激活的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM