Skip to content

Commit

Permalink
Move tree create to happen when the data provider is set
Browse files Browse the repository at this point in the history
, not when the view is activated.

Fixes #79889
  • Loading branch information
alexr00 committed Aug 27, 2019
1 parent efae59a commit 98574d6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/vs/workbench/api/browser/mainThreadTreeViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ export class MainThreadTreeViews extends Disposable implements MainThreadTreeVie
this._dataProviders.set(treeViewId, dataProvider);
const viewer = this.getTreeView(treeViewId);
if (viewer) {
viewer.dataProvider = dataProvider;
// Order is important here. The internal tree isn't created until the dataProvider is set.
// Set all other properties first!
viewer.showCollapseAllAction = !!options.showCollapseAll;
viewer.canSelectMany = !!options.canSelectMany;
viewer.dataProvider = dataProvider;
this.registerListeners(treeViewId, viewer);
this._proxy.$setVisible(treeViewId, viewer.visible);
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/vs/workbench/browser/parts/views/customView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ export class CustomTreeView extends Disposable implements ITreeView {
}

set dataProvider(dataProvider: ITreeViewDataProvider | undefined) {
if (this.tree === undefined) {
this.createTree();
}

if (dataProvider) {
this._dataProvider = new class implements ITreeViewDataProvider {
async getChildren(node: ITreeItem): Promise<ITreeItem[]> {
Expand Down Expand Up @@ -578,7 +582,6 @@ export class CustomTreeView extends Disposable implements ITreeView {

private activate() {
if (!this.activated) {
this.createTree();
this.progressService.withProgress({ location: this.viewContainer.id }, () => this.extensionService.activateByEvent(`onView:${this.id}`))
.then(() => timeout(2000))
.then(() => {
Expand Down

0 comments on commit 98574d6

Please sign in to comment.