@@ -65,37 +65,40 @@ export class GitExtension implements IGitExtension, IDisposable {
65
65
oldValue : this . _pathRepository
66
66
} ;
67
67
if ( v === null ) {
68
- this . _pathRepository = null ;
69
- if ( change . newValue !== change . oldValue ) {
70
- this . _refreshStatus ( ) ;
71
- this . _repositoryChanged . emit ( change ) ;
72
- }
68
+ this . _pendingReadyPromise += 1 ;
69
+ this . _readyPromise . then ( ( ) => {
70
+ this . _pathRepository = null ;
71
+ this . _pendingReadyPromise -= 1 ;
72
+
73
+ if ( change . newValue !== change . oldValue ) {
74
+ this . refreshStatus ( ) ;
75
+ this . _repositoryChanged . emit ( change ) ;
76
+ }
77
+ } ) ;
73
78
} else {
74
- void this . ready . then ( ( ) => {
75
- this . _isReady = false ;
76
- this . _readyPromise = this . showTopLevel ( v )
77
- . then ( results => {
78
- if ( results . code === 0 ) {
79
- this . _pathRepository = results . top_repo_path ;
80
- change . newValue = results . top_repo_path ;
81
- } else {
82
- this . _pathRepository = null ;
83
- }
84
-
85
- if ( change . newValue !== change . oldValue ) {
86
- this . _refreshStatus ( ) ;
87
- this . _repositoryChanged . emit ( change ) ;
88
- }
89
- } )
90
- . catch ( reason => {
91
- console . error (
92
- `Fail to find git top level for path ${ v } .\n${ reason } `
93
- ) ;
94
-
95
- void this . _readyPromise . then ( ( ) => {
96
- this . _isReady = true ;
97
- } ) ;
98
- } ) ;
79
+ const currentReady = this . _readyPromise ;
80
+ this . _pendingReadyPromise += 1 ;
81
+ this . _readyPromise = Promise . all ( [ currentReady , this . showTopLevel ( v ) ] )
82
+ . then ( r => {
83
+ const results = r [ 1 ] ;
84
+ if ( results . code === 0 ) {
85
+ this . _pathRepository = results . top_repo_path ;
86
+ change . newValue = results . top_repo_path ;
87
+ } else {
88
+ this . _pathRepository = null ;
89
+ }
90
+
91
+ if ( change . newValue !== change . oldValue ) {
92
+ this . refreshStatus ( ) ;
93
+ this . _repositoryChanged . emit ( change ) ;
94
+ }
95
+ } )
96
+ . catch ( reason => {
97
+ console . error ( `Fail to find git top level for path ${ v } .\n${ reason } ` ) ;
98
+ } ) ;
99
+
100
+ void this . _readyPromise . then ( ( ) => {
101
+ this . _pendingReadyPromise -= 1 ;
99
102
} ) ;
100
103
}
101
104
}
@@ -162,12 +165,9 @@ export class GitExtension implements IGitExtension, IDisposable {
162
165
return null ;
163
166
}
164
167
165
- return (
166
- '/' +
167
- PathExt . join (
168
- PathExt . relative ( this . _serverRoot , this . pathRepository ) ,
169
- path || ''
170
- )
168
+ return PathExt . join (
169
+ PathExt . relative ( this . _serverRoot , this . pathRepository ) ,
170
+ path || ''
171
171
) ;
172
172
}
173
173
@@ -760,7 +760,7 @@ export class GitExtension implements IGitExtension, IDisposable {
760
760
* Test whether the model is ready.
761
761
*/
762
762
get isReady ( ) : boolean {
763
- return this . _isReady ;
763
+ return this . _pendingReadyPromise === 0 ;
764
764
}
765
765
766
766
/**
@@ -787,7 +787,7 @@ export class GitExtension implements IGitExtension, IDisposable {
787
787
private _diffProviders : { [ key : string ] : Git . IDiffCallback } = { } ;
788
788
private _isDisposed = false ;
789
789
private _readyPromise : Promise < void > = Promise . resolve ( ) ;
790
- private _isReady = true ;
790
+ private _pendingReadyPromise = 0 ;
791
791
private _poll : Poll ;
792
792
private _headChanged = new Signal < IGitExtension , void > ( this ) ;
793
793
private _repositoryChanged = new Signal <
0 commit comments