@@ -21,6 +21,9 @@ import { OpenerService, open, TreeNode, ExpandableTreeNode, CompositeTreeNode, S
21
21
import { FileNavigatorTree , WorkspaceRootNode , WorkspaceNode } from './navigator-tree' ;
22
22
import { WorkspaceService } from '@theia/workspace/lib/browser' ;
23
23
import { FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state' ;
24
+ import { ProgressService } from '@theia/core/lib/common/progress-service' ;
25
+ import { Deferred } from '@theia/core/lib/common/promise-util' ;
26
+ import { Disposable } from '@theia/core/lib/common/disposable' ;
24
27
25
28
@injectable ( )
26
29
export class FileNavigatorModel extends FileTreeModel {
@@ -30,12 +33,41 @@ export class FileNavigatorModel extends FileTreeModel {
30
33
@inject ( WorkspaceService ) protected readonly workspaceService : WorkspaceService ;
31
34
@inject ( FrontendApplicationStateService ) protected readonly applicationState : FrontendApplicationStateService ;
32
35
36
+ @inject ( ProgressService )
37
+ protected readonly progressService : ProgressService ;
38
+
33
39
@postConstruct ( )
34
40
protected init ( ) : void {
35
41
super . init ( ) ;
42
+ this . reportBusyProgress ( ) ;
36
43
this . initializeRoot ( ) ;
37
44
}
38
45
46
+ protected readonly pendingBusyProgress = new Map < string , Deferred < void > > ( ) ;
47
+ protected reportBusyProgress ( ) : void {
48
+ this . toDispose . push ( this . onDidChangeBusy ( node => {
49
+ const pending = this . pendingBusyProgress . get ( node . id ) ;
50
+ if ( pending ) {
51
+ if ( ! node . busy ) {
52
+ pending . resolve ( ) ;
53
+ this . pendingBusyProgress . delete ( node . id ) ;
54
+ }
55
+ return ;
56
+ }
57
+ if ( node . busy ) {
58
+ const progress = new Deferred < void > ( ) ;
59
+ this . pendingBusyProgress . set ( node . id , progress ) ;
60
+ this . progressService . withProgress ( '' , 'explorer' , ( ) => progress . promise ) ;
61
+ }
62
+ } ) ) ;
63
+ this . toDispose . push ( Disposable . create ( ( ) => {
64
+ for ( const pending of this . pendingBusyProgress . values ( ) ) {
65
+ pending . resolve ( ) ;
66
+ }
67
+ this . pendingBusyProgress . clear ( ) ;
68
+ } ) ) ;
69
+ }
70
+
39
71
protected async initializeRoot ( ) : Promise < void > {
40
72
await Promise . all ( [
41
73
this . applicationState . reachedState ( 'initialized_layout' ) ,
0 commit comments