Fixes #98083: Add onStartup activation event

This commit is contained in:
Alex Dima
2020-06-01 23:04:02 +02:00
parent 7e9abe577d
commit 827cbdd472
4 changed files with 40 additions and 0 deletions

View File

@@ -432,11 +432,37 @@ export abstract class AbstractExtHostExtensionService implements ExtHostExtensio
this._logService.error(err);
});
for (const desc of this._registry.getAllExtensionDescriptions()) {
if (desc.activationEvents) {
for (const activationEvent of desc.activationEvents) {
if (/^onStartup:/.test(activationEvent)) {
const strTime = activationEvent.substr('onStartup:'.length);
const time = parseInt(strTime, 10);
if (!isNaN(time)) {
this._activateDelayed(desc, activationEvent, time);
}
}
}
}
}
this._disposables.add(this._extHostWorkspace.onDidChangeWorkspace((e) => this._handleWorkspaceContainsEagerExtensions(e.added)));
const folders = this._extHostWorkspace.workspace ? this._extHostWorkspace.workspace.folders : [];
return this._handleWorkspaceContainsEagerExtensions(folders);
}
private _activateDelayed(desc: IExtensionDescription, activationEvent: string, delayMs: number): void {
setTimeout(() => {
this._activateById(desc.identifier, {
startup: true,
extensionId: desc.identifier,
activationEvent: activationEvent
}).then(undefined, (err) => {
this._logService.error(err);
});
}, delayMs);
}
private _handleWorkspaceContainsEagerExtensions(folders: ReadonlyArray<vscode.WorkspaceFolder>): Promise<void> {
if (folders.length === 0) {
return Promise.resolve(undefined);