Skip to content

Commit 37243cb

Browse files
committed
Adopt implicit activation event collector for extensions contributing notebook serializers
Ref microsoft#134127
1 parent 1e47b51 commit 37243cb

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/vs/workbench/contrib/notebook/browser/services/notebookServiceImpl.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ export class NotebookProviderInfoStore extends Disposable {
100100
builtinProvidersFromCache.set(builtin.id, this.add(builtin));
101101
});
102102

103+
103104
for (const extension of extensions) {
105+
const implicitActivationEvents: string[] = [];
104106
for (const notebookContribution of extension.value) {
105107

106108
if (!notebookContribution.type) {
@@ -114,6 +116,7 @@ export class NotebookProviderInfoStore extends Disposable {
114116
if (!existing.extension && extension.description.isBuiltin && builtins.find(builtin => builtin.id === notebookContribution.type)) {
115117
// we are registering an extension which is using the same view type which is already cached
116118
builtinProvidersFromCache.get(notebookContribution.type)?.dispose();
119+
implicitActivationEvents.push(`onNotebookSerializer:${notebookContribution.type}`);
117120
} else {
118121
extension.collector.error(`Notebook type '${notebookContribution.type}' already used`);
119122
continue;
@@ -129,7 +132,9 @@ export class NotebookProviderInfoStore extends Disposable {
129132
providerDisplayName: extension.description.displayName ?? extension.description.identifier.value,
130133
exclusive: false
131134
}));
135+
132136
}
137+
extension.implicitActivationEventsCollector.addImplicitActivationEvents(implicitActivationEvents);
133138
}
134139

135140
const mementoObject = this._memento.getMemento(StorageScope.PROFILE, StorageTarget.MACHINE);
@@ -606,20 +611,7 @@ export class NotebookService extends Disposable implements INotebookService {
606611
}
607612

608613
await this._extensionService.whenInstalledExtensionsRegistered();
609-
610-
const info = this._notebookProviderInfoStore?.get(viewType);
611-
const waitFor: Promise<any>[] = [Event.toPromise(Event.filter(this.onAddViewType, () => {
612-
return this._notebookProviders.has(viewType);
613-
}))];
614-
615-
if (info && info.extension) {
616-
const extensionManifest = await this._extensionService.getExtension(info.extension.value);
617-
if (extensionManifest?.activationEvents && extensionManifest.activationEvents.indexOf(`onNotebook:${viewType}`) >= 0) {
618-
waitFor.push(this._extensionService._activateById(info.extension, { startup: false, activationEvent: `onNotebook:${viewType}}`, extensionId: info.extension }));
619-
}
620-
}
621-
622-
await Promise.race(waitFor);
614+
await this._extensionService.activateByEvent(`onNotebookSerializer:${viewType}`);
623615

624616
return this._notebookProviders.has(viewType);
625617
}

0 commit comments

Comments
 (0)