@@ -65,37 +65,40 @@ export class GitExtension implements IGitExtension, IDisposable {
6565 oldValue : this . _pathRepository
6666 } ;
6767 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+ } ) ;
7378 } 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 ;
99102 } ) ;
100103 }
101104 }
@@ -162,12 +165,9 @@ export class GitExtension implements IGitExtension, IDisposable {
162165 return null ;
163166 }
164167
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 || ''
171171 ) ;
172172 }
173173
@@ -760,7 +760,7 @@ export class GitExtension implements IGitExtension, IDisposable {
760760 * Test whether the model is ready.
761761 */
762762 get isReady ( ) : boolean {
763- return this . _isReady ;
763+ return this . _pendingReadyPromise === 0 ;
764764 }
765765
766766 /**
@@ -787,7 +787,7 @@ export class GitExtension implements IGitExtension, IDisposable {
787787 private _diffProviders : { [ key : string ] : Git . IDiffCallback } = { } ;
788788 private _isDisposed = false ;
789789 private _readyPromise : Promise < void > = Promise . resolve ( ) ;
790- private _isReady = true ;
790+ private _pendingReadyPromise = 0 ;
791791 private _poll : Poll ;
792792 private _headChanged = new Signal < IGitExtension , void > ( this ) ;
793793 private _repositoryChanged = new Signal <
0 commit comments