From 98574d61ca1763323baaafe2ab49839964b7e93d Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 27 Aug 2019 14:02:31 +0200 Subject: [PATCH] Move tree create to happen when the data provider is set , not when the view is activated. Fixes #79889 --- src/vs/workbench/api/browser/mainThreadTreeViews.ts | 4 +++- src/vs/workbench/browser/parts/views/customView.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadTreeViews.ts b/src/vs/workbench/api/browser/mainThreadTreeViews.ts index 3c2e1c7080177..db7d95f0d2231 100644 --- a/src/vs/workbench/api/browser/mainThreadTreeViews.ts +++ b/src/vs/workbench/api/browser/mainThreadTreeViews.ts @@ -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 { diff --git a/src/vs/workbench/browser/parts/views/customView.ts b/src/vs/workbench/browser/parts/views/customView.ts index 2fcbf196e0d3a..956b6c10e0ae9 100644 --- a/src/vs/workbench/browser/parts/views/customView.ts +++ b/src/vs/workbench/browser/parts/views/customView.ts @@ -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 { @@ -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(() => {