Skip to content

Commit

Permalink
Fix TOC items expanding on second settings editor open
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jan 29, 2019
1 parent 95e33c7 commit ccb98c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/vs/workbench/parts/preferences/browser/tocTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,23 @@ class TOCTreeDelegate implements IListVirtualDelegate<SettingsTreeElement> {
}
}

export function createTOCIterator(model: TOCTreeModel | SettingsTreeGroupElement): Iterator<ITreeElement<SettingsTreeGroupElement>> {
export function createTOCIterator(model: TOCTreeModel | SettingsTreeGroupElement, tree: TOCTree): Iterator<ITreeElement<SettingsTreeGroupElement>> {
const groupChildren = <SettingsTreeGroupElement[]>model.children.filter(c => c instanceof SettingsTreeGroupElement);
const groupsIt = Iterator.fromArray(groupChildren);


return Iterator.map(groupsIt, g => {
let nodeExists = true;
try { tree.getNode(g); } catch (e) { nodeExists = false; }

const hasGroupChildren = g.children.some(c => c instanceof SettingsTreeGroupElement);

return {
element: g,
collapsed: nodeExists ? undefined : true,
collapsible: hasGroupChildren,
children: g instanceof SettingsTreeGroupElement ?
createTOCIterator(g) :
createTOCIterator(g, tree) :
undefined
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ export class SettingsEditor2 extends BaseEditor {
}

private refreshTOCTree(): void {
this.tocTree.setChildren(null, createTOCIterator(this.tocTreeModel));
this.tocTree.setChildren(null, createTOCIterator(this.tocTreeModel, this.tocTree));
}

private updateModifiedLabelForKey(key: string): void {
Expand Down

0 comments on commit ccb98c2

Please sign in to comment.