Skip to content

Commit ffc7aa3

Browse files
committed
adopt setting to override exp and opt in for existing users
1 parent 1befa37 commit ffc7aa3

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/extension.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { commands, extensions, ExtensionContext, LogOutputChannel, Terminal, Uri, window, workspace } from 'vscode';
1+
import { commands, ExtensionContext, extensions, LogOutputChannel, Terminal, Uri, window, workspace } from 'vscode';
22
import { PythonEnvironment, PythonEnvironmentApi, PythonProjectCreator } from './api';
33
import { ensureCorrectVersion } from './common/extVersion';
44
import { registerLogger, traceError, traceInfo } from './common/logging';
@@ -75,27 +75,38 @@ import { registerPyenvFeatures } from './managers/pyenv/main';
7575
async function collectEnvironmentInfo(
7676
context: ExtensionContext,
7777
envManagers: EnvironmentManagers,
78-
projectManager: PythonProjectManager
78+
projectManager: PythonProjectManager,
7979
): Promise<string> {
8080
const info: string[] = [];
81-
81+
82+
// Attempt to set setting of config.python.useEnvironmentsExtension to true
83+
try {
84+
const config = workspace.getConfiguration('python');
85+
await config.update('useEnvironmentsExtension', true, true);
86+
} catch (err) {
87+
traceError(
88+
'Failed to set config.python.useEnvironmentsExtension to true. Please do so manually in your user settings now to ensure the Python environment extension is enabled during upcoming experimentation.',
89+
err,
90+
);
91+
}
92+
8293
try {
8394
// Extension version
8495
const extensionVersion = context.extension?.packageJSON?.version || 'unknown';
8596
info.push(`Extension Version: ${extensionVersion}`);
86-
97+
8798
// Python extension version
8899
const pythonExtension = extensions.getExtension('ms-python.python');
89100
const pythonVersion = pythonExtension?.packageJSON?.version || 'not installed';
90101
info.push(`Python Extension Version: ${pythonVersion}`);
91-
102+
92103
// Environment managers
93104
const managers = envManagers.managers;
94105
info.push(`\nRegistered Environment Managers (${managers.length}):`);
95-
managers.forEach(manager => {
106+
managers.forEach((manager) => {
96107
info.push(` - ${manager.id} (${manager.displayName})`);
97108
});
98-
109+
99110
// Available environments
100111
const allEnvironments: PythonEnvironment[] = [];
101112
for (const manager of managers) {
@@ -106,7 +117,7 @@ async function collectEnvironmentInfo(
106117
info.push(` Error getting environments from ${manager.id}: ${err}`);
107118
}
108119
}
109-
120+
110121
info.push(`\nTotal Available Environments: ${allEnvironments.length}`);
111122
if (allEnvironments.length > 0) {
112123
info.push('Environment Details:');
@@ -117,7 +128,7 @@ async function collectEnvironmentInfo(
117128
info.push(` ... and ${allEnvironments.length - 10} more environments`);
118129
}
119130
}
120-
131+
121132
// Python projects
122133
const projects = projectManager.getProjects();
123134
info.push(`\nPython Projects (${projects.length}):`);
@@ -133,18 +144,17 @@ async function collectEnvironmentInfo(
133144
info.push(` Error getting environment: ${err}`);
134145
}
135146
}
136-
147+
137148
// Current settings (non-sensitive)
138149
const config = workspace.getConfiguration('python-envs');
139150
info.push('\nExtension Settings:');
140151
info.push(` Default Environment Manager: ${config.get('defaultEnvManager')}`);
141152
info.push(` Default Package Manager: ${config.get('defaultPackageManager')}`);
142153
info.push(` Terminal Auto Activation: ${config.get('terminal.autoActivationType')}`);
143-
144154
} catch (err) {
145155
info.push(`\nError collecting environment information: ${err}`);
146156
}
147-
157+
148158
return info.join('\n');
149159
}
150160

@@ -366,11 +376,11 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
366376
commands.registerCommand('python-envs.reportIssue', async () => {
367377
try {
368378
const issueData = await collectEnvironmentInfo(context, envManagers, projectManager);
369-
379+
370380
await commands.executeCommand('workbench.action.openIssueReporter', {
371381
extensionId: 'ms-python.vscode-python-envs',
372382
issueTitle: '[Python Environments] ',
373-
issueBody: `<!-- Please describe the issue you're experiencing -->\n\n<!-- The following information was automatically generated -->\n\n<details>\n<summary>Environment Information</summary>\n\n\`\`\`\n${issueData}\n\`\`\`\n\n</details>`
383+
issueBody: `<!-- Please describe the issue you're experiencing -->\n\n<!-- The following information was automatically generated -->\n\n<details>\n<summary>Environment Information</summary>\n\n\`\`\`\n${issueData}\n\`\`\`\n\n</details>`,
374384
});
375385
} catch (error) {
376386
window.showErrorMessage(`Failed to open issue reporter: ${error}`);

0 commit comments

Comments
 (0)