@@ -21,7 +21,7 @@ import { registerAction2, Action2 } from 'vs/platform/actions/common/actions';
2121import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
2222import { StopWatch } from 'vs/base/common/stopwatch' ;
2323import { VSBuffer } from 'vs/base/common/buffer' ;
24- import { IExtensionHost , ExtensionHostKind } from 'vs/workbench/services/extensions/common/extensions' ;
24+ import { IExtensionHost , ExtensionHostKind , ActivationKind } from 'vs/workbench/services/extensions/common/extensions' ;
2525import { ExtensionActivationReason } from 'vs/workbench/api/common/extHostExtensionActivator' ;
2626
2727// Enable to see detailed message communication between window and extension host
@@ -48,6 +48,7 @@ export class ExtensionHostManager extends Disposable {
4848 */
4949 private _proxy : Promise < { value : ExtHostExtensionServiceShape ; } | null > | null ;
5050 private _resolveAuthorityAttempt : number ;
51+ private _hasStarted = false ;
5152
5253 constructor (
5354 extensionHost : IExtensionHost ,
@@ -65,6 +66,7 @@ export class ExtensionHostManager extends Disposable {
6566 this . onDidExit = this . _extensionHost . onExit ;
6667 this . _proxy = this . _extensionHost . start ( ) ! . then (
6768 ( protocol ) => {
69+ this . _hasStarted = true ;
6870 return { value : this . _createExtensionHostCustomers ( protocol ) } ;
6971 } ,
7072 ( err ) => {
@@ -74,7 +76,7 @@ export class ExtensionHostManager extends Disposable {
7476 }
7577 ) ;
7678 this . _proxy . then ( ( ) => {
77- initialActivationEvents . forEach ( ( activationEvent ) => this . activateByEvent ( activationEvent ) ) ;
79+ initialActivationEvents . forEach ( ( activationEvent ) => this . activateByEvent ( activationEvent , ActivationKind . Normal ) ) ;
7880 this . _register ( registerLatencyTestProvider ( {
7981 measure : ( ) => this . measure ( )
8082 } ) ) ;
@@ -217,14 +219,18 @@ export class ExtensionHostManager extends Disposable {
217219 return proxy . $activate ( extension , reason ) ;
218220 }
219221
220- public activateByEvent ( activationEvent : string ) : Promise < void > {
222+ public activateByEvent ( activationEvent : string , activationKind : ActivationKind ) : Promise < void > {
223+ if ( activationKind === ActivationKind . Immediate && ! this . _hasStarted ) {
224+ return Promise . resolve ( ) ;
225+ }
226+
221227 if ( ! this . _cachedActivationEvents . has ( activationEvent ) ) {
222- this . _cachedActivationEvents . set ( activationEvent , this . _activateByEvent ( activationEvent ) ) ;
228+ this . _cachedActivationEvents . set ( activationEvent , this . _activateByEvent ( activationEvent , activationKind ) ) ;
223229 }
224230 return this . _cachedActivationEvents . get ( activationEvent ) ! ;
225231 }
226232
227- private async _activateByEvent ( activationEvent : string ) : Promise < void > {
233+ private async _activateByEvent ( activationEvent : string , activationKind : ActivationKind ) : Promise < void > {
228234 if ( ! this . _proxy ) {
229235 return ;
230236 }
@@ -234,7 +240,7 @@ export class ExtensionHostManager extends Disposable {
234240 // i.e. the extension host could not be started
235241 return ;
236242 }
237- return proxy . value . $activateByEvent ( activationEvent ) ;
243+ return proxy . value . $activateByEvent ( activationEvent , activationKind ) ;
238244 }
239245
240246 public async getInspectPort ( tryEnableInspector : boolean ) : Promise < number > {
0 commit comments