Skip to content

Commit a2f18cf

Browse files
committed
fix: only skip activation if user explicitly disables extension
Previous logic used config.get() which was affected by defaultValue from other extensions' package.json. Now we use inspect() to check if the user has EXPLICITLY set useEnvironmentsExtension to false. - If user sets to true: activate - If user sets to false: don't activate - If user doesn't set anything: activate (default behavior) - If only defaultValue exists: ignored, activate anyway This is more robust and matches user intent.
1 parent 142555b commit a2f18cf

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/extension.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,24 @@ import { registerPoetryFeatures } from './managers/poetry/main';
8787
import { registerPyenvFeatures } from './managers/pyenv/main';
8888

8989
export async function activate(context: ExtensionContext): Promise<PythonEnvironmentApi | undefined> {
90-
// Check for explicit test environment (set via .vscode-test.mjs env vars)
91-
const isTestEnvironment = process.env.VSC_PYTHON_SMOKE_TEST === '1' ||
92-
process.env.VSC_PYTHON_E2E_TEST === '1' ||
93-
process.env.VSC_PYTHON_INTEGRATION_TEST === '1';
94-
95-
// Use inspect() to check if the setting has been explicitly set by the user.
96-
// This is important because config.get() may return a defaultValue from other
97-
// extensions' package.json (like ms-python.python setting it to false), even
98-
// when those extensions aren't installed.
90+
// Use inspect() to check if the user has EXPLICITLY disabled this extension.
91+
// Only skip activation if someone explicitly set useEnvironmentsExtension to false.
92+
// This ignores defaultValues from other extensions' package.json and defaults to
93+
// activating the extension if no explicit setting exists.
9994
const config = getConfiguration('python');
10095
const inspection = config.inspect<boolean>('useEnvironmentsExtension');
10196

102-
// If no one has explicitly set this setting, default to true
103-
const hasExplicitValue = inspection?.globalValue !== undefined ||
104-
inspection?.workspaceValue !== undefined ||
105-
inspection?.workspaceFolderValue !== undefined;
97+
// Check for explicit false values (user deliberately disabled the extension)
98+
const explicitlyDisabled = inspection?.globalValue === false ||
99+
inspection?.workspaceValue === false ||
100+
inspection?.workspaceFolderValue === false;
101+
102+
// DEBUG: Log to stdout which will appear in CI logs
103+
console.log('[python-envs] activate() called');
104+
console.log('[python-envs] inspection:', JSON.stringify(inspection));
105+
console.log('[python-envs] explicitlyDisabled:', explicitlyDisabled);
106106

107-
const useEnvironmentsExtension = isTestEnvironment ||
108-
(hasExplicitValue ? config.get<boolean>('useEnvironmentsExtension', true) : true);
107+
const useEnvironmentsExtension = !explicitlyDisabled;
109108
traceInfo(`Experiment Status: useEnvironmentsExtension setting set to ${useEnvironmentsExtension}`);
110109
if (!useEnvironmentsExtension) {
111110
traceWarn(

0 commit comments

Comments
 (0)