@@ -67,23 +67,28 @@ interface IExplorerViewStyles {
67
67
listDropBackground ?: Color ;
68
68
}
69
69
70
- // Accepts a single or multiple workspace folders
71
- function hasExpandedRootChild ( tree : WorkbenchCompressibleAsyncDataTree < ExplorerItem | ExplorerItem [ ] , ExplorerItem , FuzzyScore > , treeInput : ExplorerItem | ExplorerItem [ ] ) : boolean {
72
- const inputsToCheck = [ ] ;
73
- if ( Array . isArray ( treeInput ) ) {
74
- inputsToCheck . push ( ...treeInput . filter ( folder => tree . hasNode ( folder ) && ! tree . isCollapsed ( folder ) ) ) ;
75
- } else {
76
- inputsToCheck . push ( treeInput ) ;
77
- }
78
-
79
- for ( const folder of inputsToCheck ) {
80
- for ( const [ , child ] of folder . children . entries ( ) ) {
81
- if ( tree . hasNode ( child ) && tree . isCollapsible ( child ) && ! tree . isCollapsed ( child ) ) {
82
- return true ;
70
+ function hasExpandedRootChild ( tree : WorkbenchCompressibleAsyncDataTree < ExplorerItem | ExplorerItem [ ] , ExplorerItem , FuzzyScore > , treeInput : ExplorerItem [ ] ) : boolean {
71
+ for ( const folder of treeInput ) {
72
+ if ( tree . hasNode ( folder ) && ! tree . isCollapsed ( folder ) ) {
73
+ for ( const [ , child ] of folder . children . entries ( ) ) {
74
+ if ( tree . hasNode ( child ) && tree . isCollapsible ( child ) && ! tree . isCollapsed ( child ) ) {
75
+ return true ;
76
+ }
83
77
}
84
78
}
85
79
}
80
+ return false ;
81
+ }
86
82
83
+ /**
84
+ * Whether or not any of the nodes in the tree are expanded
85
+ */
86
+ function hasExpandedNode ( tree : WorkbenchCompressibleAsyncDataTree < ExplorerItem | ExplorerItem [ ] , ExplorerItem , FuzzyScore > , treeInput : ExplorerItem [ ] ) : boolean {
87
+ for ( const folder of treeInput ) {
88
+ if ( tree . hasNode ( folder ) && ! tree . isCollapsed ( folder ) ) {
89
+ return true ;
90
+ }
91
+ }
87
92
return false ;
88
93
}
89
94
@@ -786,15 +791,6 @@ export class ExplorerView extends ViewPane implements IExplorerView {
786
791
this . tree . domFocus ( ) ;
787
792
}
788
793
789
- const treeInput = this . tree . getInput ( ) ;
790
- if ( Array . isArray ( treeInput ) ) {
791
- treeInput . forEach ( folder => {
792
- folder . children . forEach ( child => this . tree . hasNode ( child ) && this . tree . expand ( child , true ) ) ;
793
- } ) ;
794
-
795
- return ;
796
- }
797
-
798
794
this . tree . expandAll ( ) ;
799
795
}
800
796
@@ -871,7 +867,9 @@ export class ExplorerView extends ViewPane implements IExplorerView {
871
867
if ( treeInput === undefined ) {
872
868
return ;
873
869
}
874
- this . viewHasSomeCollapsibleRootItem . set ( hasExpandedRootChild ( this . tree , treeInput ) ) ;
870
+ const treeInputArray = Array . isArray ( treeInput ) ? treeInput : Array . from ( treeInput . children . values ( ) ) ;
871
+ // Has collapsible root when anything is expanded
872
+ this . viewHasSomeCollapsibleRootItem . set ( hasExpandedNode ( this . tree , treeInputArray ) ) ;
875
873
}
876
874
877
875
styleListDropBackground ( styles : IExplorerViewStyles ) : void {
0 commit comments