@@ -41,6 +41,9 @@ import { Extensions as ActionExtensions, IWorkbenchActionRegistry } from 'vs/wor
4141import { getRemoteName } from 'vs/platform/remote/common/remoteHosts' ;
4242import { IRemoteAgentEnvironment } from 'vs/platform/remote/common/remoteAgentEnvironment' ;
4343import { WebWorkerExtensionHost } from 'vs/workbench/services/extensions/browser/webWorkerExtensionHost' ;
44+ import { IExtensionActivationHost as IWorkspaceContainsActivationHost , checkGlobFileExists , checkActivateWorkspaceContainsExtension } from 'vs/workbench/api/common/shared/workspaceContains' ;
45+ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace' ;
46+ import { exists } from 'vs/base/node/pfs' ;
4447
4548class DeltaExtensionsQueueItem {
4649 constructor (
@@ -75,6 +78,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
7578 @IHostService private readonly _hostService : IHostService ,
7679 @IRemoteExplorerService private readonly _remoteExplorerService : IRemoteExplorerService ,
7780 @IExtensionGalleryService private readonly _extensionGalleryService : IExtensionGalleryService ,
81+ @IWorkspaceContextService private readonly _contextService : IWorkspaceContextService ,
7882 ) {
7983 super (
8084 instantiationService ,
@@ -308,6 +312,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
308312
309313 let shouldActivate = false ;
310314 let shouldActivateReason : string | null = null ;
315+ let hasWorkspaceContains = false ;
311316 if ( Array . isArray ( extensionDescription . activationEvents ) ) {
312317 for ( let activationEvent of extensionDescription . activationEvents ) {
313318 // TODO@joao : there's no easy way to contribute this
@@ -329,10 +334,7 @@ export class ExtensionService extends AbstractExtensionService implements IExten
329334 }
330335
331336 if ( / ^ w o r k s p a c e C o n t a i n s / . test ( activationEvent ) ) {
332- // do not trigger a search, just activate in this case...
333- shouldActivate = true ;
334- shouldActivateReason = activationEvent ;
335- break ;
337+ hasWorkspaceContains = true ;
336338 }
337339
338340 if ( activationEvent === 'onStartupFinished' ) {
@@ -347,6 +349,24 @@ export class ExtensionService extends AbstractExtensionService implements IExten
347349 await Promise . all (
348350 this . _extensionHostManagers . map ( extHostManager => extHostManager . activate ( extensionDescription . identifier , { startup : false , extensionId : extensionDescription . identifier , activationEvent : shouldActivateReason ! } ) )
349351 ) . then ( ( ) => { } ) ;
352+ } else if ( hasWorkspaceContains ) {
353+ const workspace = await this . _contextService . getCompleteWorkspace ( ) ;
354+ const forceUsingSearch = ! ! this . _environmentService . configuration . remoteAuthority ;
355+ const host : IWorkspaceContainsActivationHost = {
356+ folders : workspace . folders . map ( folder => folder . uri ) ,
357+ forceUsingSearch : forceUsingSearch ,
358+ exists : ( path ) => exists ( path ) ,
359+ checkExists : ( folders , includes , token ) => this . _instantiationService . invokeFunction ( ( accessor ) => checkGlobFileExists ( accessor , folders , includes , token ) )
360+ } ;
361+
362+ const result = await checkActivateWorkspaceContainsExtension ( host , extensionDescription ) ;
363+ if ( ! result ) {
364+ return ;
365+ }
366+
367+ await Promise . all (
368+ this . _extensionHostManagers . map ( extHostManager => extHostManager . activate ( extensionDescription . identifier , { startup : false , extensionId : extensionDescription . identifier , activationEvent : result . activationEvent } ) )
369+ ) . then ( ( ) => { } ) ;
350370 }
351371 }
352372
0 commit comments