Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --Related Issues: <!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --- VS Code Version: 1.54.1 OS Version: Linux x64 5.8.0-44-generic Steps to Reproduce: a root folder (files-exclude-sample) that folder create two nested folders (child1, child2) root folder (files-exclude-sample), create a workspace definition file (files-exclude-) root folder (files-exclude-sample), create a .vscode folder .vscode folder create a file to previous steps, just clone this GitHub repo: VSCode, open the workspace (files-exclude-) looks ok. You have tree root folders (files-exclude-sample, child1 and child2) ! you expand all three folder you can see something like ! specified in root folder , child1 and child2 are excluded from child1 folder child1 folder is collapsed (not removed from explorer tree) and it appears inside root folder (files-exclude-sample) folder ! expected behavior is that child1 is not collapsed and it does not appear inside root folder <!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported direct to the extension publisher. The 'Help Report Issue' dialog can assist with this. --
the owner of the file explorer is
I acknowledge this issue. MR workspace support with when one root folder is a subfolder of another root folder has some issues. If somebody is passionate about fixing this let me know and I can provide pointers
Created fixing this
Thanks to a great pr by this is now fixed

Discussion:
return this.model.findClosest(resource); } <ins> findClosestRoot(resource: URI): ExplorerItem | null { const parentRoots = this.model.roots.filter(r => this.uriIdentityService.extUri.isEqualOrParent(resource, r.resource)) .sort((first, second) => second.resource.path.length - first.resource.path.length); return parentRoots.length ? parentRoots[0] : null; } </ins> async setEditable(stat: ExplorerItem, data: IEditableData | null): Promise<void> { if (!this.view) { return;

// If undefined is passed checks if any element is currently being edited. isEditable(stat: ExplorerItem | undefined): boolean; findClosest(resource: URI): ExplorerItem | null; <ins> findClosestRoot(resource: URI): ExplorerItem | null; </ins> refresh(): Promise<void>; setToCopy(stats: ExplorerItem[], cut: boolean): Promise<void>; isCut(stat: ExplorerItem): boolean;

} // Expand all stats in the parent chain. <del> let item: ExplorerItem | undefined = this.explorerService.roots.filter(i => this.uriIdentityService.extUri.isEqualOrParent(resource, i.resource)) // Take the root that is the closest to the stat #72299 .sort((first, second) => second.resource.path.length - first.resource.path.length)[0]; </del> <ins> let item: ExplorerItem | null = this.explorerService.findClosestRoot(resource); </ins> while (item && item.resource.toString() !== resource.toString()) { try {

item = child; break; } <del> item = undefined; </del> <ins> item = null; </ins> } }

* Makes sure that visible editors are always shown in the explorer even if they are filtered out by settings. */ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> { <del> private hiddenExpressionPerRoot: Map<string, CachedParsedExpression>; private uriVisibilityMap = new Map<URI, boolean>(); </del> <ins> private hiddenExpressionPerRoot = new Map<string, CachedParsedExpression>(); </ins> private editorsAffectingFilter = new Set<IEditorInput>(); private _onDidChange = new Emitter<void>(); private toDispose: IDisposable[] = [];

@IEditorService private readonly editorService: IEditorService, @IUriIdentityService private readonly uriIdentityService: IUriIdentityService ) { <del> this.hiddenExpressionPerRoot = new Map<string, CachedParsedExpression>(); </del> this.toDispose.push(this.contextService.onDidChangeWorkspaceFolders(() => this.updateConfiguration())); this.toDispose.push(this.configurationService.onDidChangeConfiguration((e) => { if (e.affectsConfiguration('files.exclude')) {

this.toDispose.push(this.editorService.onDidVisibleEditorsChange(() => { const editors = this.editorService.visibleEditors; let shouldFire = false; <del> this.uriVisibilityMap.forEach((visible, uri) => { if (!visible) { editors.forEach(e => { if (e.resource && this.uriIdentityService.extUri.isEqualOrParent(e.resource, uri)) { // A filtered resource suddenly became visible since user opened an editor shouldFire = true; } }); </del> <ins> for (const e of editors) { if (!e.resource) { continue; </ins> } <del> }); this.editorsAffectingFilter.forEach(e => { </del> <ins> const stat = this.explorerService.findClosest(e.resource); if (stat && stat.isExcluded) { // A filtered resource suddenly became visible since user opened an editor shouldFire = true; break; } } for (const e of this.editorsAffectingFilter) { </ins> if (!editors.includes(e)) { // Editor that was affecting filtering is no longer visible shouldFire = true; <ins> break; </ins> } <del> }); </del> <ins> } </ins> if (shouldFire) { this.editorsAffectingFilter.clear(); <del> this.uriVisibilityMap.clear(); </del> this._onDidChange.fire(); } }));

if (shouldFire) { this.editorsAffectingFilter.clear(); <del> this.uriVisibilityMap.clear(); </del> this._onDidChange.fire(); } } filter(stat: ExplorerItem, parentVisibility: TreeVisibility): boolean { <del> const cachedVisibility = this.uriVisibilityMap.get(stat.resource); if (typeof cachedVisibility === 'boolean') { return cachedVisibility; } const isVisible = this.isVisible(stat, parentVisibility); this.uriVisibilityMap.set(stat.resource, isVisible); return isVisible; </del> <ins> return this.isVisible(stat, parentVisibility); </ins> } private isVisible(stat: ExplorerItem, parentVisibility: TreeVisibility): boolean {

stat.isExcluded = true; const editors = this.editorService.visibleEditors; const editor = editors.find(e => e.resource && this.uriIdentityService.extUri.isEqualOrParent(e.resource, stat.resource)); <del> if (editor) { </del> <ins> if (editor && stat.root === this.explorerService.findClosestRoot(stat.resource)) { </ins> this.editorsAffectingFilter.add(editor); return true; // Show all opened files and their parents }