Skip to content

Commit dbc867f

Browse files
Remove "Reset to Default" context menu command (#530)
The "Reset to Default" context menu command was confusing to users as it was unclear what it did and how to undo its effects. Based on team discussion, the decision was made to remove this option entirely. Fixes #483. --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: eleanorjboyd <[email protected]>
1 parent ba1d393 commit dbc867f

File tree

4 files changed

+11
-49
lines changed

4 files changed

+11
-49
lines changed

package.json

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,6 @@
160160
"category": "Python",
161161
"icon": "$(check)"
162162
},
163-
{
164-
"command": "python-envs.reset",
165-
"title": "%python-envs.reset.title%",
166-
"category": "Python",
167-
"icon": "$(sync)"
168-
},
169163
{
170164
"command": "python-envs.remove",
171165
"title": "%python-envs.remove.title%",
@@ -281,10 +275,6 @@
281275
"command": "python-envs.setEnv",
282276
"when": "false"
283277
},
284-
{
285-
"command": "python-envs.reset",
286-
"when": "false"
287-
},
288278
{
289279
"command": "python-envs.remove",
290280
"when": "false"
@@ -406,10 +396,6 @@
406396
"group": "inline",
407397
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
408398
},
409-
{
410-
"command": "python-envs.reset",
411-
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
412-
},
413399
{
414400
"command": "python-envs.createTerminal",
415401
"group": "inline",

package.nls.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"python-envs.createAny.title": "Create Environment",
2424
"python-envs.set.title": "Set Project Environment",
2525
"python-envs.setEnv.title": "Set As Project Environment",
26-
"python-envs.reset.title": "Reset to Default",
2726
"python-envs.remove.title": "Delete Environment",
2827
"python-envs.refreshAllManagers.title": "Refresh All Environment Managers",
2928
"python-envs.refreshPackages.title": "Refresh Packages List",

src/extension.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
refreshPackagesCommand,
3333
removeEnvironmentCommand,
3434
removePythonProject,
35-
resetEnvironmentCommand,
3635
runAsTaskCommand,
3736
runInDedicatedTerminalCommand,
3837
runInTerminalCommand,
@@ -61,6 +60,7 @@ import { EnvManagerView } from './features/views/envManagersView';
6160
import { ProjectView } from './features/views/projectView';
6261
import { PythonStatusBarImpl } from './features/views/pythonStatusBar';
6362
import { updateViewsAndStatus } from './features/views/revealHandler';
63+
import { ProjectItem } from './features/views/treeViewItems';
6464
import { EnvironmentManagers, ProjectCreators, PythonProjectManager } from './internal.api';
6565
import { registerSystemPythonFeatures } from './managers/builtin/main';
6666
import { SysPythonManager } from './managers/builtin/sysPythonManager';
@@ -265,9 +265,6 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
265265
commands.registerCommand('python-envs.setEnv', async (item) => {
266266
await setEnvironmentCommand(item, envManagers, projectManager);
267267
}),
268-
commands.registerCommand('python-envs.reset', async (item) => {
269-
await resetEnvironmentCommand(item, envManagers, projectManager);
270-
}),
271268
commands.registerCommand('python-envs.setEnvManager', async () => {
272269
await setEnvManagerCommand(envManagers, projectManager);
273270
}),
@@ -285,7 +282,16 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
285282
await addPythonProjectCommand(resource, projectManager, envManagers, projectCreators);
286283
}),
287284
commands.registerCommand('python-envs.removePythonProject', async (item) => {
288-
await resetEnvironmentCommand(item, envManagers, projectManager);
285+
// Clear environment association before removing project
286+
if (item instanceof ProjectItem) {
287+
const uri = item.project.uri;
288+
const manager = envManagers.getEnvironmentManager(uri);
289+
if (manager) {
290+
manager.set(uri, undefined);
291+
} else {
292+
traceError(`No environment manager found for ${uri.fsPath}`);
293+
}
294+
}
289295
await removePythonProject(item, projectManager);
290296
}),
291297
commands.registerCommand('python-envs.clearCache', async () => {

src/features/envCommands.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -329,35 +329,6 @@ async function setEnvironmentForProjects(
329329
await em.setEnvironments(uris, environment);
330330
}
331331

332-
export async function resetEnvironmentCommand(
333-
context: unknown,
334-
em: EnvironmentManagers,
335-
wm: PythonProjectManager,
336-
): Promise<void> {
337-
if (context instanceof ProjectItem) {
338-
const view = context as ProjectItem;
339-
return resetEnvironmentCommand(view.project.uri, em, wm);
340-
} else if (context instanceof Uri) {
341-
const uri = context as Uri;
342-
const manager = em.getEnvironmentManager(uri);
343-
if (manager) {
344-
manager.set(uri, undefined);
345-
} else {
346-
showErrorMessage(`No environment manager found for: ${uri.fsPath}`);
347-
traceError(`No environment manager found for ${uri.fsPath}`);
348-
}
349-
return;
350-
} else if (context === undefined) {
351-
const pw = await pickProject(wm.getProjects());
352-
if (pw) {
353-
return resetEnvironmentCommand(pw.uri, em, wm);
354-
}
355-
return;
356-
}
357-
traceError(`Invalid context for unset environment command: ${context}`);
358-
showErrorMessage('Invalid context for unset environment');
359-
}
360-
361332
export async function setEnvManagerCommand(em: EnvironmentManagers, wm: PythonProjectManager): Promise<void> {
362333
const projects = await pickProjectMany(wm.getProjects());
363334
if (projects && projects.length > 0) {

0 commit comments

Comments
 (0)