Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 authored and afonsobspinto committed Dec 3, 2017
1 parent addebdd commit 101f7a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
32 changes: 22 additions & 10 deletions src/vs/workbench/browser/parts/views/treeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class TreeView extends TreeViewsViewletPanel {
private treeInputPromise: TPromise<void>;

private dataProviderElementChangeListener: IDisposable;
private elementsToRefresh: ITreeItem[] = [];

constructor(
options: IViewletViewOptions,
Expand Down Expand Up @@ -113,10 +114,6 @@ export class TreeView extends TreeViewsViewletPanel {
return createActionItem(action, this.keybindingService, this.messageService);
}

public setVisible(visible: boolean): TPromise<void> {
return super.setVisible(visible);
}

private setInput(): TPromise<void> {
if (this.tree) {
if (!this.treeInputPromise) {
Expand Down Expand Up @@ -172,15 +169,30 @@ export class TreeView extends TreeViewsViewletPanel {
}
}

protected updateTreeVisibility(tree: WorkbenchTree, isVisible: boolean): void {
super.updateTreeVisibility(tree, isVisible);
if (isVisible && this.elementsToRefresh.length) {
this.doRefresh(this.elementsToRefresh);
this.elementsToRefresh = [];
}
}

private refresh(elements: ITreeItem[]): void {
if (elements) {
for (const element of elements) {
this.tree.refresh(element);
}
} else {
if (!elements) {
const root: ITreeItem = this.tree.getInput();
root.children = null; // reset children
this.tree.refresh(root);
elements = [root];
}
if (this.isVisible() && this.isExpanded()) {
this.doRefresh(elements);
} else {
this.elementsToRefresh.push(...elements);
}
}

private doRefresh(elements: ITreeItem[]): void {
for (const element of elements) {
this.tree.refresh(element);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/browser/parts/views/viewsViewlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export abstract class TreeViewsViewletPanel extends ViewsViewletPanel {
super.dispose();
}

private updateTreeVisibility(tree: WorkbenchTree, isVisible: boolean): void {
protected updateTreeVisibility(tree: WorkbenchTree, isVisible: boolean): void {
if (!tree) {
return;
}
Expand Down

0 comments on commit 101f7a0

Please sign in to comment.