@@ -56,6 +56,7 @@ import { IDialogService, IPromptButton } from 'vs/platform/dialogs/common/dialog
56
56
import { IUpdateService , StateType } from 'vs/platform/update/common/update' ;
57
57
import { isEngineValid } from 'vs/platform/extensions/common/extensionValidator' ;
58
58
import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity' ;
59
+ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
59
60
60
61
interface IExtensionStateProvider < T > {
61
62
( extension : Extension ) : T ;
@@ -879,6 +880,7 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
879
880
@IUserDataSyncEnablementService private readonly userDataSyncEnablementService : IUserDataSyncEnablementService ,
880
881
@IUpdateService private readonly updateService : IUpdateService ,
881
882
@IUriIdentityService private readonly uriIdentityService : IUriIdentityService ,
883
+ @IWorkspaceContextService private readonly workspaceContextService : IWorkspaceContextService ,
882
884
) {
883
885
super ( ) ;
884
886
const preferPreReleasesValue = configurationService . getValue ( '_extensions.preferPreReleases' ) ;
@@ -1004,21 +1006,31 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
1004
1006
1005
1007
private async onDidChangeRunningExtensions ( added : ReadonlyArray < IExtensionDescription > , removed : ReadonlyArray < IExtensionDescription > ) : Promise < void > {
1006
1008
const changedExtensions : IExtension [ ] = [ ] ;
1007
- const extsNotInstalled : IExtensionInfo [ ] = [ ] ;
1009
+ const extensionsToFetch : IExtensionDescription [ ] = [ ] ;
1008
1010
for ( const desc of added ) {
1009
1011
const extension = this . installed . find ( e => areSameExtensions ( { id : desc . identifier . value , uuid : desc . uuid } , e . identifier ) ) ;
1010
1012
if ( extension ) {
1011
1013
changedExtensions . push ( extension ) ;
1012
1014
} else {
1013
- extsNotInstalled . push ( { id : desc . identifier . value , uuid : desc . uuid } ) ;
1015
+ extensionsToFetch . push ( desc ) ;
1014
1016
}
1015
1017
}
1016
- if ( extsNotInstalled . length ) {
1017
- const extensions = await this . getExtensions ( extsNotInstalled , CancellationToken . None ) ;
1018
- for ( const extension of extensions ) {
1019
- changedExtensions . push ( extension ) ;
1018
+ const workspaceExtensions : IExtensionDescription [ ] = [ ] ;
1019
+ for ( const desc of removed ) {
1020
+ if ( this . workspaceContextService . isInsideWorkspace ( desc . extensionLocation ) ) {
1021
+ workspaceExtensions . push ( desc ) ;
1022
+ } else {
1023
+ extensionsToFetch . push ( desc ) ;
1020
1024
}
1021
1025
}
1026
+ if ( extensionsToFetch . length ) {
1027
+ const extensions = await this . getExtensions ( extensionsToFetch . map ( e => ( { id : e . identifier . value , uuid : e . uuid } ) ) , CancellationToken . None ) ;
1028
+ changedExtensions . push ( ...extensions ) ;
1029
+ }
1030
+ if ( workspaceExtensions . length ) {
1031
+ const extensions = await this . getResourceExtensions ( workspaceExtensions . map ( e => e . extensionLocation ) , true )
1032
+ changedExtensions . push ( ...extensions ) ;
1033
+ }
1022
1034
for ( const changedExtension of changedExtensions ) {
1023
1035
this . _onChange . fire ( changedExtension ) ;
1024
1036
}
@@ -1237,13 +1249,6 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
1237
1249
const toRemove : string [ ] = [ ] ;
1238
1250
1239
1251
const extensionsToCheck = [ ...this . local ] ;
1240
-
1241
- const notExistingRunningExtensions = this . extensionService . extensions . filter ( e => ! this . local . some ( local => areSameExtensions ( { id : e . identifier . value , uuid : e . uuid } , local . identifier ) ) ) ;
1242
- if ( notExistingRunningExtensions . length ) {
1243
- const extensions = await this . getExtensions ( notExistingRunningExtensions . map ( e => ( { id : e . identifier . value } ) ) , CancellationToken . None ) ;
1244
- extensionsToCheck . push ( ...extensions ) ;
1245
- }
1246
-
1247
1252
for ( const extension of extensionsToCheck ) {
1248
1253
const runtimeState = extension . runtimeState ;
1249
1254
if ( ! runtimeState || runtimeState . action !== ExtensionRuntimeActionType . RestartExtensions ) {
@@ -1267,6 +1272,18 @@ export class ExtensionsWorkbenchService extends Disposable implements IExtension
1267
1272
toRemove . push ( extension . identifier . id ) ;
1268
1273
}
1269
1274
}
1275
+
1276
+ for ( const extension of this . extensionService . extensions ) {
1277
+ if ( extension . isUnderDevelopment ) {
1278
+ continue ;
1279
+ }
1280
+ if ( extensionsToCheck . some ( e => areSameExtensions ( { id : extension . identifier . value , uuid : extension . uuid } , e . identifier ) ) ) {
1281
+ continue ;
1282
+ }
1283
+ // Extension is running but doesn't exist locally. Remove it from running extensions.
1284
+ toRemove . push ( extension . identifier . value ) ;
1285
+ }
1286
+
1270
1287
if ( toAdd . length || toRemove . length ) {
1271
1288
if ( await this . extensionService . stopExtensionHosts ( nls . localize ( 'restart' , "Enable or Disable extensions" ) ) ) {
1272
1289
await this . extensionService . startExtensionHosts ( { toAdd, toRemove } ) ;
0 commit comments