visual-studio-codetreeviewvscode-extensionstreeviewitem

Activate command on TreeViewItem click, VSCode Extension


I would like to run a command on the click of a tree view item, rather than in a menu that comes up. Right now in my package.json, I have this:

    {
      "command": "test.view.showError",
      "when": "view == test.view && viewItem == test",
      "group": "inline"
    }

Right now, "inline" will put an icon next to the words which you have to click to run the command, but I would like the command to run when I click on the node itself.

What do I change "group" to? Or do I do something different entirely?

Thanks


Solution

  • You have to set the command property on the TreeItem instance.

    command?: Command

    The command that should be executed when the tree item is selected.

    https://code.visualstudio.com/docs/extensionAPI/vscode-api#TreeItem