@@ -532,8 +532,7 @@ interface CachedParsedExpression {
532
532
* Makes sure that visible editors are always shown in the explorer even if they are filtered out by settings.
533
533
*/
534
534
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 > ( ) ;
537
536
private editorsAffectingFilter = new Set < IEditorInput > ( ) ;
538
537
private _onDidChange = new Emitter < void > ( ) ;
539
538
private toDispose : IDisposable [ ] = [ ] ;
@@ -545,7 +544,6 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
545
544
@IEditorService private readonly editorService : IEditorService ,
546
545
@IUriIdentityService private readonly uriIdentityService : IUriIdentityService
547
546
) {
548
- this . hiddenExpressionPerRoot = new Map < string , CachedParsedExpression > ( ) ;
549
547
this . toDispose . push ( this . contextService . onDidChangeWorkspaceFolders ( ( ) => this . updateConfiguration ( ) ) ) ;
550
548
this . toDispose . push ( this . configurationService . onDidChangeConfiguration ( ( e ) => {
551
549
if ( e . affectsConfiguration ( 'files.exclude' ) ) {
@@ -555,26 +553,30 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
555
553
this . toDispose . push ( this . editorService . onDidVisibleEditorsChange ( ( ) => {
556
554
const editors = this . editorService . visibleEditors ;
557
555
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 ;
566
560
}
567
- } ) ;
568
561
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 ) {
570
571
if ( ! editors . includes ( e ) ) {
571
572
// Editor that was affecting filtering is no longer visible
572
573
shouldFire = true ;
574
+ break ;
573
575
}
574
- } ) ;
576
+ }
577
+
575
578
if ( shouldFire ) {
576
579
this . editorsAffectingFilter . clear ( ) ;
577
- this . uriVisibilityMap . clear ( ) ;
578
580
this . _onDidChange . fire ( ) ;
579
581
}
580
582
} ) ) ;
@@ -603,21 +605,12 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
603
605
604
606
if ( shouldFire ) {
605
607
this . editorsAffectingFilter . clear ( ) ;
606
- this . uriVisibilityMap . clear ( ) ;
607
608
this . _onDidChange . fire ( ) ;
608
609
}
609
610
}
610
611
611
612
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 ) ;
621
614
}
622
615
623
616
private isVisible ( stat : ExplorerItem , parentVisibility : TreeVisibility ) : boolean {
@@ -636,7 +629,8 @@ export class FilesFilter implements ITreeFilter<ExplorerItem, FuzzyScore> {
636
629
stat . isExcluded = true ;
637
630
const editors = this . editorService . visibleEditors ;
638
631
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 ) {
640
634
this . editorsAffectingFilter . add ( editor ) ;
641
635
return true ; // Show all opened files and their parents
642
636
}
0 commit comments