Skip to content

Commit

Permalink
[plugin] restore previous tree view state before synching it
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Kosyakov <[email protected]>
  • Loading branch information
akosyakov committed Jul 25, 2019
1 parent 7c78b38 commit 9604944
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/main/browser/view/tree-views-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-ext/src/plugin/tree/tree-views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ class TreeViewExtImpl<T> extends Disposable {
async getChildren(parentId: string): Promise<TreeViewItem[] | undefined> {
// 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);
Expand Down

0 comments on commit 9604944

Please sign in to comment.