Monday, 15 February 2021

Refresh Treeview in VS Code JS extension

I am developing a VS Code extension using JavaScript, not TypeScript. And I need to reload the treeview content when the user clicks the refresh button. I am doing that like it is said in the extension guide (https://code.visualstudio.com/api/extension-guides/tree-view#updating-tree-view-content):

const vscode = require('vscode');

class DataTreeviewProvider {
  constructor(value) {
    // ...
  }

  getTreeItem(value) {
    // ...
  }

  getChildren(value) {
    // ...
  }
  
  _onDidChangeTreeData = new vscode.EventEmitter();
  onDidChangeTreeData = this._onDidChangeTreeData.event;
  
  refresh() {
    this._onDidChangeTreeData.fire();
  }
}

class Data extends vscode.TreeItem {
  constructor(collapsibleState) {
    super(label, collapsibleState);
  }
}

It works when the refresh button is clicked once. But on the next clicks it does not refresh the data and I can't figure out how to do it in JS, because all the docs are written in TS.



from Refresh Treeview in VS Code JS extension

No comments:

Post a Comment