Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to run some remote extensions locally #143626

Merged
merged 1 commit into from
Feb 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/vs/workbench/services/extensions/browser/extensionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,18 @@ export class ExtensionService extends AbstractExtensionService implements IExten
// takes care of duplicates and picks a running location for each extension
this._runningLocation = this._runningLocationClassifier.determineRunningLocation(localExtensions, remoteExtensions);

// Some remote extensions could run locally in the web worker, so store them
const remoteExtensionsThatNeedToRunLocally = filterByRunningLocation(remoteExtensions, this._runningLocation, ExtensionRunningLocation.LocalWebWorker);
localExtensions = filterByRunningLocation(localExtensions, this._runningLocation, ExtensionRunningLocation.LocalWebWorker);
remoteExtensions = filterByRunningLocation(remoteExtensions, this._runningLocation, ExtensionRunningLocation.Remote);

// Add locally the remote extensions that need to run locally in the web worker
for (const ext of remoteExtensionsThatNeedToRunLocally) {
if (!includes(localExtensions, ext.identifier)) {
localExtensions.push(ext);
}
}

const result = this._registry.deltaExtensions(remoteExtensions.concat(localExtensions), []);
if (result.removedDueToLooping.length > 0) {
this._logOrShowMessage(Severity.Error, nls.localize('looping', "The following extensions contain dependency loops and have been disabled: {0}", result.removedDueToLooping.map(e => `'${e.identifier.value}'`).join(', ')));
Expand Down Expand Up @@ -241,4 +250,13 @@ function filterByRunningLocation(extensions: IExtensionDescription[], runningLoc
return extensions.filter(ext => runningLocation.get(ExtensionIdentifier.toKey(ext.identifier)) === desiredRunningLocation);
}

function includes(extensions: IExtensionDescription[], identifier: ExtensionIdentifier): boolean {
for (const extension of extensions) {
if (ExtensionIdentifier.equals(extension.identifier, identifier)) {
return true;
}
}
return false;
}

registerSingleton(IExtensionService, ExtensionService);