Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/client/envExt/api.internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,19 @@ export function shouldEnvExtHandleActivation(): boolean {
}

let _useExt: boolean | undefined;
export function shouldUseEnvExtension(): boolean {
const config = getConfiguration('python');
const inExpSetting = config?.get<boolean>('useEnvironmentsExtension', false) ?? false;
return inExpSetting && shouldEnvExtHandleActivation();
}

export function useEnvExtension(): boolean {
if (_useExt !== undefined) {
return _useExt;
}
const config = getConfiguration('python');
const inExpSetting = config?.get<boolean>('useEnvironmentsExtension', false) ?? false;
// If extension is installed and in experiment, then use it.
_useExt = !!getExtension(ENVS_EXTENSION_ID) && inExpSetting;
// Use the extension only when it is enabled and its own activation logic
// will expose the API.
_useExt = shouldUseEnvExtension();
return _useExt;
}

Expand Down
9 changes: 9 additions & 0 deletions src/test/common/terminals/activator/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ suite('shouldEnvExtHandleActivation', () => {
assert.strictEqual(extapi.shouldEnvExtHandleActivation(), false);
});

test('Does not use envs extension when workspace enables it but user settings disable activation', () => {
getExtensionStub.returns({ id: extapi.ENVS_EXTENSION_ID });
getConfigurationStub.returns({
get: () => true,
inspect: () => ({ globalValue: false, workspaceValue: true }),
});
assert.strictEqual(extapi.shouldUseEnvExtension(), false);
});

test('Returns false when envs extension is installed but workspaceValue is false', () => {
getExtensionStub.returns({ id: extapi.ENVS_EXTENSION_ID });
getConfigurationStub.returns({
Expand Down