@@ -14,7 +14,7 @@ import { IPager, singlePagePager } from 'vs/base/common/paging';
14
14
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
15
15
import {
16
16
IExtensionGalleryService , ILocalExtension , IGalleryExtension , IQueryOptions ,
17
- InstallExtensionEvent , DidUninstallExtensionEvent , IExtensionIdentifier , InstallOperation , InstallOptions , WEB_EXTENSION_TAG , InstallExtensionResult ,
17
+ InstallExtensionEvent , DidUninstallExtensionEvent , InstallOperation , InstallOptions , WEB_EXTENSION_TAG , InstallExtensionResult ,
18
18
IExtensionsControlManifest , InstallVSIXOptions , IExtensionInfo , IExtensionQueryOptions , IDeprecationInfo
19
19
} from 'vs/platform/extensionManagement/common/extensionManagement' ;
20
20
import { IWorkbenchExtensionEnablementService , EnablementState , IExtensionManagementServerService , IExtensionManagementServer , IWorkbenchExtensionManagementService , DefaultIconPath } from 'vs/workbench/services/extensionManagement/common/extensionManagement' ;
@@ -34,7 +34,7 @@ import * as resources from 'vs/base/common/resources';
34
34
import { CancellationToken } from 'vs/base/common/cancellation' ;
35
35
import { IStorageService , StorageScope , StorageTarget } from 'vs/platform/storage/common/storage' ;
36
36
import { IFileService } from 'vs/platform/files/common/files' ;
37
- import { IExtensionManifest , ExtensionType , IExtension as IPlatformExtension , TargetPlatform , ExtensionIdentifier } from 'vs/platform/extensions/common/extensions' ;
37
+ import { IExtensionManifest , ExtensionType , IExtension as IPlatformExtension , TargetPlatform , ExtensionIdentifier , IExtensionIdentifier } from 'vs/platform/extensions/common/extensions' ;
38
38
import { ILanguageService } from 'vs/editor/common/languages/language' ;
39
39
import { IProductService } from 'vs/platform/product/common/productService' ;
40
40
import { FileAccess } from 'vs/base/common/network' ;
@@ -1331,7 +1331,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
1331
1331
this . ignoreAutoUpdate ( new ExtensionKey ( identifier , manifest . version ) ) ;
1332
1332
}
1333
1333
1334
- return this . local . filter ( local => areSameExtensions ( local . identifier , identifier ) ) [ 0 ] ;
1334
+ return this . waitAndGetInstalledExtension ( identifier ) ;
1335
1335
}
1336
1336
1337
1337
private async installFromGallery ( extension : IExtension , gallery : IGalleryExtension , installOptions ?: InstallOptions ) : Promise < IExtension > {
@@ -1343,13 +1343,26 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
1343
1343
} else {
1344
1344
await this . extensionManagementService . installFromGallery ( gallery , installOptions ) ;
1345
1345
}
1346
- return this . local . filter ( local => areSameExtensions ( local . identifier , gallery . identifier ) ) [ 0 ] ;
1346
+ return this . waitAndGetInstalledExtension ( gallery . identifier ) ;
1347
1347
} finally {
1348
1348
this . installing = this . installing . filter ( e => e !== extension ) ;
1349
1349
this . _onChange . fire ( this . local . filter ( e => areSameExtensions ( e . identifier , extension . identifier ) ) [ 0 ] ) ;
1350
1350
}
1351
1351
}
1352
1352
1353
+ private async waitAndGetInstalledExtension ( identifier : IExtensionIdentifier ) : Promise < IExtension > {
1354
+ let installedExtension = this . local . find ( local => areSameExtensions ( local . identifier , identifier ) ) ;
1355
+ if ( ! installedExtension ) {
1356
+ await Event . toPromise ( Event . filter ( this . onChange , e => ! ! e && this . local . some ( local => areSameExtensions ( local . identifier , identifier ) ) ) ) ;
1357
+ }
1358
+ installedExtension = this . local . find ( local => areSameExtensions ( local . identifier , identifier ) ) ;
1359
+ if ( ! installedExtension ) {
1360
+ // This should not happen
1361
+ throw new Error ( 'Extension should have been installed' ) ;
1362
+ }
1363
+ return installedExtension ;
1364
+ }
1365
+
1353
1366
private promptAndSetEnablement ( extensions : IExtension [ ] , enablementState : EnablementState ) : Promise < any > {
1354
1367
const enable = enablementState === EnablementState . EnabledGlobally || enablementState === EnablementState . EnabledWorkspace ;
1355
1368
if ( enable ) {
0 commit comments