Skip to content

Commit 0dcf930

Browse files
committed
1 parent 9b2ee7f commit 0dcf930

File tree

1 file changed

+20
-26
lines changed

1 file changed

+20
-26
lines changed

src/vs/workbench/contrib/files/browser/views/explorerViewer.ts

+20-26
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,7 @@ interface CachedParsedExpression {
532532
* Makes sure that visible editors are always shown in the explorer even if they are filtered out by settings.
533533
*/
534534
export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
535-
private hiddenExpressionPerRoot: Map<string, CachedParsedExpression>;
536-
private uriVisibilityMap = new Map<URI, boolean>();
535+
private hiddenExpressionPerRoot = new Map<string, CachedParsedExpression>();
537536
private editorsAffectingFilter = new Set<IEditorInput>();
538537
private _onDidChange = new Emitter<void>();
539538
private toDispose: IDisposable[] = [];
@@ -545,7 +544,6 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
545544
@IEditorService private readonly editorService: IEditorService,
546545
@IUriIdentityService private readonly uriIdentityService: IUriIdentityService
547546
) {
548-
this.hiddenExpressionPerRoot = new Map<string, CachedParsedExpression>();
549547
this.toDispose.push(this.contextService.onDidChangeWorkspaceFolders(() => this.updateConfiguration()));
550548
this.toDispose.push(this.configurationService.onDidChangeConfiguration((e) => {
551549
if (e.affectsConfiguration('files.exclude')) {
@@ -555,26 +553,30 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
555553
this.toDispose.push(this.editorService.onDidVisibleEditorsChange(() => {
556554
const editors = this.editorService.visibleEditors;
557555
let shouldFire = false;
558-
this.uriVisibilityMap.forEach((visible, uri) => {
559-
if (!visible) {
560-
editors.forEach(e => {
561-
if (e.resource && this.uriIdentityService.extUri.isEqualOrParent(e.resource, uri)) {
562-
// A filtered resource suddenly became visible since user opened an editor
563-
shouldFire = true;
564-
}
565-
});
556+
557+
for (const e of editors) {
558+
if (!e.resource) {
559+
continue;
566560
}
567-
});
568561

569-
this.editorsAffectingFilter.forEach(e => {
562+
const stat = this.explorerService.findClosest(e.resource);
563+
if (stat && stat.isExcluded) {
564+
// A filtered resource suddenly became visible since user opened an editor
565+
shouldFire = true;
566+
break;
567+
}
568+
}
569+
570+
for (const e of this.editorsAffectingFilter) {
570571
if (!editors.includes(e)) {
571572
// Editor that was affecting filtering is no longer visible
572573
shouldFire = true;
574+
break;
573575
}
574-
});
576+
}
577+
575578
if (shouldFire) {
576579
this.editorsAffectingFilter.clear();
577-
this.uriVisibilityMap.clear();
578580
this._onDidChange.fire();
579581
}
580582
}));
@@ -603,21 +605,12 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
603605

604606
if (shouldFire) {
605607
this.editorsAffectingFilter.clear();
606-
this.uriVisibilityMap.clear();
607608
this._onDidChange.fire();
608609
}
609610
}
610611

611612
filter(stat: ExplorerItem, parentVisibility: TreeVisibility): boolean {
612-
const cachedVisibility = this.uriVisibilityMap.get(stat.resource);
613-
if (typeof cachedVisibility === 'boolean') {
614-
return cachedVisibility;
615-
}
616-
617-
const isVisible = this.isVisible(stat, parentVisibility);
618-
this.uriVisibilityMap.set(stat.resource, isVisible);
619-
620-
return isVisible;
613+
return this.isVisible(stat, parentVisibility);
621614
}
622615

623616
private isVisible(stat: ExplorerItem, parentVisibility: TreeVisibility): boolean {
@@ -636,7 +629,8 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
636629
stat.isExcluded = true;
637630
const editors = this.editorService.visibleEditors;
638631
const editor = editors.find(e => e.resource && this.uriIdentityService.extUri.isEqualOrParent(e.resource, stat.resource));
639-
if (editor) {
632+
const closestRoot = this.explorerService.findClosest(stat.resource)!.root;
633+
if (editor && stat.root === closestRoot) {
640634
this.editorsAffectingFilter.add(editor);
641635
return true; // Show all opened files and their parents
642636
}

0 commit comments

Comments
 (0)