@@ -173,7 +173,7 @@ export class ExplorerView extends ViewPane implements IExplorerView {
173
173
private viewHasSomeCollapsibleRootItem : IContextKey < boolean > ;
174
174
private viewVisibleContextKey : IContextKey < boolean > ;
175
175
176
-
176
+ private setTreeInputPromise : Promise < void > | undefined ;
177
177
private horizontalScrolling : boolean | undefined ;
178
178
179
179
private dragHandler ! : DelayedDragHandler ;
@@ -522,7 +522,7 @@ export class ExplorerView extends ViewPane implements IExplorerView {
522
522
523
523
// save view state
524
524
this . _register ( this . storageService . onWillSaveState ( ( ) => {
525
- this . storageService . store ( ExplorerView . TREE_VIEW_STATE_STORAGE_KEY , JSON . stringify ( this . tree . getViewState ( ) ) , StorageScope . WORKSPACE , StorageTarget . MACHINE ) ;
525
+ this . storeTreeViewState ( ) ;
526
526
} ) ) ;
527
527
}
528
528
@@ -540,6 +540,10 @@ export class ExplorerView extends ViewPane implements IExplorerView {
540
540
}
541
541
}
542
542
543
+ private storeTreeViewState ( ) {
544
+ this . storageService . store ( ExplorerView . TREE_VIEW_STATE_STORAGE_KEY , JSON . stringify ( this . tree . getViewState ( ) ) , StorageScope . WORKSPACE , StorageTarget . MACHINE ) ;
545
+ }
546
+
543
547
private setContextKeys ( stat : ExplorerItem | null | undefined ) : void {
544
548
const folders = this . contextService . getWorkspace ( ) . folders ;
545
549
const resource = stat ? stat . resource : folders [ folders . length - 1 ] . uri ;
@@ -666,6 +670,11 @@ export class ExplorerView extends ViewPane implements IExplorerView {
666
670
return Promise . resolve ( undefined ) ;
667
671
}
668
672
673
+ // Wait for the last execution to complete before executing
674
+ if ( this . setTreeInputPromise ) {
675
+ await this . setTreeInputPromise ;
676
+ }
677
+
669
678
const initialInputSetup = ! this . tree . getInput ( ) ;
670
679
if ( initialInputSetup ) {
671
680
perf . mark ( 'code/willResolveExplorer' ) ;
@@ -688,7 +697,7 @@ export class ExplorerView extends ViewPane implements IExplorerView {
688
697
}
689
698
690
699
const previousInput = this . tree . getInput ( ) ;
691
- const promise = this . tree . setInput ( input , viewState ) . then ( async ( ) => {
700
+ const promise = this . setTreeInputPromise = this . tree . setInput ( input , viewState ) . then ( async ( ) => {
692
701
if ( Array . isArray ( input ) ) {
693
702
if ( ! viewState || previousInput instanceof ExplorerItem ) {
694
703
// There is no view state for this workspace (we transitioned from a folder workspace?), expand up to five roots.
@@ -883,6 +892,8 @@ export class ExplorerView extends ViewPane implements IExplorerView {
883
892
const treeInputArray = Array . isArray ( treeInput ) ? treeInput : Array . from ( treeInput . children . values ( ) ) ;
884
893
// Has collapsible root when anything is expanded
885
894
this . viewHasSomeCollapsibleRootItem . set ( hasExpandedNode ( this . tree , treeInputArray ) ) ;
895
+ // synchronize state to cache
896
+ this . storeTreeViewState ( ) ;
886
897
}
887
898
888
899
override dispose ( ) : void {
0 commit comments