@@ -22,14 +22,14 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
22
22
23
23
private readonly _resolveAuthorityRequests : Map < string , DeferredPromise < ResolverResult > > ;
24
24
private readonly _connectionTokens : Map < string , string > ;
25
- private readonly _canonicalURIRequests : Map < string , DeferredPromise < URI > > ;
25
+ private readonly _canonicalURIRequests : Map < string , { input : URI ; result : DeferredPromise < URI > } > ;
26
26
private _canonicalURIProvider : ( ( uri : URI ) => Promise < URI > ) | null ;
27
27
28
28
constructor ( @IProductService productService : IProductService ) {
29
29
super ( ) ;
30
30
this . _resolveAuthorityRequests = new Map < string , DeferredPromise < ResolverResult > > ( ) ;
31
31
this . _connectionTokens = new Map < string , string > ( ) ;
32
- this . _canonicalURIRequests = new Map < string , DeferredPromise < URI > > ( ) ;
32
+ this . _canonicalURIRequests = new Map ( ) ;
33
33
this . _canonicalURIProvider = null ;
34
34
35
35
RemoteAuthorities . setServerRootPath ( getRemoteServerRootPath ( productService ) ) ;
@@ -44,12 +44,15 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
44
44
45
45
async getCanonicalURI ( uri : URI ) : Promise < URI > {
46
46
const key = uri . toString ( ) ;
47
- if ( ! this . _canonicalURIRequests . has ( key ) ) {
48
- const request = new DeferredPromise < URI > ( ) ;
49
- this . _canonicalURIProvider ?.( uri ) . then ( ( uri ) => request . complete ( uri ) , ( err ) => request . error ( err ) ) ;
50
- this . _canonicalURIRequests . set ( key , request ) ;
47
+ const existing = this . _canonicalURIRequests . get ( key ) ;
48
+ if ( existing ) {
49
+ return existing . result . p ;
51
50
}
52
- return this . _canonicalURIRequests . get ( key ) ! . p ;
51
+
52
+ const result = new DeferredPromise < URI > ( ) ;
53
+ this . _canonicalURIProvider ?.( uri ) . then ( ( uri ) => result . complete ( uri ) , ( err ) => result . error ( err ) ) ;
54
+ this . _canonicalURIRequests . set ( key , { input : uri , result } ) ;
55
+ return result . p ;
53
56
}
54
57
55
58
getConnectionData ( authority : string ) : IRemoteConnectionData | null {
@@ -105,8 +108,8 @@ export class RemoteAuthorityResolverService extends Disposable implements IRemot
105
108
106
109
_setCanonicalURIProvider ( provider : ( uri : URI ) => Promise < URI > ) : void {
107
110
this . _canonicalURIProvider = provider ;
108
- this . _canonicalURIRequests . forEach ( ( value , key ) => {
109
- this . _canonicalURIProvider ! ( URI . parse ( key ) ) . then ( ( uri ) => value . complete ( uri ) , ( err ) => value . error ( err ) ) ;
111
+ this . _canonicalURIRequests . forEach ( ( { result , input } ) => {
112
+ this . _canonicalURIProvider ! ( input ) . then ( ( uri ) => result . complete ( uri ) , ( err ) => result . error ( err ) ) ;
110
113
} ) ;
111
114
}
112
115
}
0 commit comments