Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 authored Sep 29, 2022
1 parent c4c4814 commit bcb6c9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ export class ExtensionEnablementService extends Disposable implements IWorkbench
continue;
}

// Skip if dependency extension is disabled by extension kind
if (enablementStateOfExtension === EnablementState.DisabledByExtensionKind) {
continue;
}

// Check if the extension is a dependency or in extension pack
if (extensions.some(e =>
(options.dependencies && e.manifest.extensionDependencies?.some(id => areSameExtensions({ id }, extension.identifier)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,22 @@ suite('ExtensionEnablementService Test', () => {
assert.strictEqual(testObject.getEnablementState(target), EnablementState.EnabledWorkspace);
});

test('test enable an extension with a dependency extension that cannot be enabled', async () => {
instantiationService.stub(IExtensionManagementServerService, anExtensionManagementServerService(anExtensionManagementServer('vscode-local', instantiationService), anExtensionManagementServer('vscode-remote', instantiationService), null));
const localWorkspaceDepExtension = aLocalExtension2('pub.b', { extensionKind: ['workspace'] }, { location: URI.file(`pub.b`) });
const remoteWorkspaceExtension = aLocalExtension2('pub.a', { extensionKind: ['workspace'], extensionDependencies: ['pub.b'] }, { location: URI.file(`pub.a`).with({ scheme: Schemas.vscodeRemote }) });
const remoteWorkspaceDepExtension = aLocalExtension2('pub.b', { extensionKind: ['workspace'] }, { location: URI.file(`pub.b`).with({ scheme: Schemas.vscodeRemote }) });
installed.push(localWorkspaceDepExtension, remoteWorkspaceExtension, remoteWorkspaceDepExtension);

testObject = new TestExtensionEnablementService(instantiationService);
await (<TestExtensionEnablementService>testObject).waitUntilInitialized();

await testObject.setEnablement([remoteWorkspaceExtension], EnablementState.DisabledGlobally);
await testObject.setEnablement([remoteWorkspaceExtension], EnablementState.EnabledGlobally);
assert.ok(testObject.isEnabled(remoteWorkspaceExtension));
assert.strictEqual(testObject.getEnablementState(remoteWorkspaceExtension), EnablementState.EnabledGlobally);
});

test('test enable an extension also enables packed extensions', async () => {
installed.push(...[aLocalExtension2('pub.a', { extensionPack: ['pub.b'] }), aLocalExtension('pub.b')]);
const target = installed[0];
Expand Down

0 comments on commit bcb6c9b

Please sign in to comment.