Skip to content

Commit 22e1d42

Browse files
author
Jackson Kearl
committed
1 parent 163dd4f commit 22e1d42

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/vs/workbench/contrib/files/common/explorerModel.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,12 +318,6 @@ export class ExplorerItem {
318318

319319
const items: ExplorerItem[] = [];
320320
if (nestingConfig.enabled) {
321-
const patterns = Object.entries(nestingConfig.patterns).map(
322-
([parentPattern, childrenPatterns]) =>
323-
[parentPattern.trim(), childrenPatterns.split(',').map(p => p.trim())] as [string, string[]]);
324-
325-
const nester = new ExplorerFileNestingTrie(patterns);
326-
327321
const fileChildren: [string, ExplorerItem][] = [];
328322
const dirChildren: [string, ExplorerItem][] = [];
329323
for (const child of this.children.entries()) {
@@ -334,7 +328,7 @@ export class ExplorerItem {
334328
}
335329
}
336330

337-
const nested = nester.nest(fileChildren.map(([name]) => name));
331+
const nested = this.buildFileNester().nest(fileChildren.map(([name]) => name));
338332

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

358+
// TODO:@jkearl, share one nester across all explorer items and only build on config change
359+
private buildFileNester(): ExplorerFileNestingTrie {
360+
const nestingConfig = this.configService.getValue<IFilesConfiguration>().explorer.experimental.fileNesting;
361+
const patterns = Object.entries(nestingConfig.patterns)
362+
.filter(entry =>
363+
typeof (entry[0]) === 'string' && typeof (entry[1]) === 'string' && entry[0] && entry[1])
364+
.map(([parentPattern, childrenPatterns]) =>
365+
[parentPattern.trim(), childrenPatterns.split(',').map(p => p.trim())] as [string, string[]]);
366+
367+
return new ExplorerFileNestingTrie(patterns);
368+
}
369+
364370
/**
365371
* Removes a child element from this folder.
366372
*/

0 commit comments

Comments
 (0)