Skip to content

Commit

Permalink
Fix #141434
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson Kearl committed Jan 28, 2022
1 parent 163dd4f commit 22e1d42
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/vs/workbench/contrib/files/common/explorerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,6 @@ export class ExplorerItem {

const items: ExplorerItem[] = [];
if (nestingConfig.enabled) {
const patterns = Object.entries(nestingConfig.patterns).map(
([parentPattern, childrenPatterns]) =>
[parentPattern.trim(), childrenPatterns.split(',').map(p => p.trim())] as [string, string[]]);

const nester = new ExplorerFileNestingTrie(patterns);

const fileChildren: [string, ExplorerItem][] = [];
const dirChildren: [string, ExplorerItem][] = [];
for (const child of this.children.entries()) {
Expand All @@ -334,7 +328,7 @@ export class ExplorerItem {
}
}

const nested = nester.nest(fileChildren.map(([name]) => name));
const nested = this.buildFileNester().nest(fileChildren.map(([name]) => name));

for (const [fileEntryName, fileEntryItem] of fileChildren) {
const nestedItems = nested.get(fileEntryName);
Expand All @@ -361,6 +355,18 @@ export class ExplorerItem {
return items;
}

// TODO:@jkearl, share one nester across all explorer items and only build on config change
private buildFileNester(): ExplorerFileNestingTrie {
const nestingConfig = this.configService.getValue<IFilesConfiguration>().explorer.experimental.fileNesting;
const patterns = Object.entries(nestingConfig.patterns)
.filter(entry =>
typeof (entry[0]) === 'string' && typeof (entry[1]) === 'string' && entry[0] && entry[1])
.map(([parentPattern, childrenPatterns]) =>
[parentPattern.trim(), childrenPatterns.split(',').map(p => p.trim())] as [string, string[]]);

return new ExplorerFileNestingTrie(patterns);
}

/**
* Removes a child element from this folder.
*/
Expand Down

0 comments on commit 22e1d42

Please sign in to comment.