Skip to content

Commit

Permalink
align datatree with asyncdatatree
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Feb 5, 2019
1 parent 111c704 commit 15179be
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/vs/base/browser/ui/tree/dataTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface IDataTreeOptions<T, TFilterData = void> extends IAbstractTreeOp
export interface IDataTreeViewState {
readonly focus: string[];
readonly selection: string[];
readonly collapsed: string[];
readonly expanded: string[];
}

export class DataTree<TInput, T, TFilterData = void> extends AbstractTree<T | null, TFilterData, T | null> {
Expand Down Expand Up @@ -70,7 +70,7 @@ export class DataTree<TInput, T, TFilterData = void> extends AbstractTree<T | nu
selection.push(element);
}

return id in viewState.collapsed;
return viewState.expanded.indexOf(id) === -1;
};

this._refresh(input, isCollapsed);
Expand Down Expand Up @@ -123,20 +123,20 @@ export class DataTree<TInput, T, TFilterData = void> extends AbstractTree<T | nu
const focus = this.getFocus().map(getId);
const selection = this.getSelection().map(getId);

const collapsed: string[] = [];
const expanded: string[] = [];
const root = this.model.getNode();
const queue = [root];

while (queue.length > 0) {
const node = queue.shift()!;

if (node !== root && node.collapsed) {
collapsed.push(getId(node.element!));
if (node !== root && node.collapsible && !node.collapsed) {
expanded.push(getId(node.element!));
}

queue.push(...node.children);
}

return { focus, selection, collapsed };
return { focus, selection, expanded };
}
}

0 comments on commit 15179be

Please sign in to comment.