From 960494436cf58b5c205a86aadb5bb813893ce93b Mon Sep 17 00:00:00 2001 From: Anton Kosyakov Date: Mon, 22 Jul 2019 21:09:30 +0000 Subject: [PATCH] [plugin] restore previous tree view state before synching it Signed-off-by: Anton Kosyakov --- packages/plugin-ext/src/main/browser/view/tree-views-main.ts | 2 ++ packages/plugin-ext/src/plugin/tree/tree-views.ts | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts index 1ffe31eaf4b68..baf0b4db917f2 100644 --- a/packages/plugin-ext/src/main/browser/view/tree-views-main.ts +++ b/packages/plugin-ext/src/main/browser/view/tree-views-main.ts @@ -48,6 +48,8 @@ export class TreeViewsMainImpl implements TreeViewsMain { widget.model.viewInfo = viewInfo; if (state) { widget.restoreState(state); + // ensure that state is completely restored + await widget.model.refresh(); } else { const root: CompositeTreeNode & ExpandableTreeNode = { id: '', diff --git a/packages/plugin-ext/src/plugin/tree/tree-views.ts b/packages/plugin-ext/src/plugin/tree/tree-views.ts index b3dcecac272cb..85f69e1c0b3e1 100644 --- a/packages/plugin-ext/src/plugin/tree/tree-views.ts +++ b/packages/plugin-ext/src/plugin/tree/tree-views.ts @@ -164,6 +164,10 @@ class TreeViewExtImpl extends Disposable { async getChildren(parentId: string): Promise { // get element from a cache const parent = this.getTreeItem(parentId); + if (parentId && !parent) { + console.error(`No tree item with id '${parentId}' found.`); + return []; + } // ask data provider for children for cached element const result = await this.treeDataProvider.getChildren(parent);