diff --git a/package.json b/package.json index 4571aa6c..f630ca0a 100644 --- a/package.json +++ b/package.json @@ -160,12 +160,6 @@ "category": "Python", "icon": "$(check)" }, - { - "command": "python-envs.reset", - "title": "%python-envs.reset.title%", - "category": "Python", - "icon": "$(sync)" - }, { "command": "python-envs.remove", "title": "%python-envs.remove.title%", @@ -276,10 +270,6 @@ "command": "python-envs.setEnv", "when": "false" }, - { - "command": "python-envs.reset", - "when": "false" - }, { "command": "python-envs.remove", "when": "false" @@ -401,10 +391,6 @@ "group": "inline", "when": "view == python-projects && viewItem =~ /.*python-workspace.*/" }, - { - "command": "python-envs.reset", - "when": "view == python-projects && viewItem =~ /.*python-workspace.*/" - }, { "command": "python-envs.createTerminal", "group": "inline", diff --git a/package.nls.json b/package.nls.json index 80b8fcf6..599f2690 100644 --- a/package.nls.json +++ b/package.nls.json @@ -22,7 +22,6 @@ "python-envs.createAny.title": "Create Environment", "python-envs.set.title": "Set Project Environment", "python-envs.setEnv.title": "Set As Project Environment", - "python-envs.reset.title": "Reset to Default", "python-envs.remove.title": "Delete Environment", "python-envs.refreshAllManagers.title": "Refresh All Environment Managers", "python-envs.refreshPackages.title": "Refresh Packages List", diff --git a/src/extension.ts b/src/extension.ts index d87098b9..344bf970 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -32,7 +32,6 @@ import { refreshPackagesCommand, removeEnvironmentCommand, removePythonProject, - resetEnvironmentCommand, runAsTaskCommand, runInDedicatedTerminalCommand, runInTerminalCommand, @@ -61,6 +60,7 @@ import { EnvManagerView } from './features/views/envManagersView'; import { ProjectView } from './features/views/projectView'; import { PythonStatusBarImpl } from './features/views/pythonStatusBar'; import { updateViewsAndStatus } from './features/views/revealHandler'; +import { ProjectItem } from './features/views/treeViewItems'; import { EnvironmentManagers, ProjectCreators, PythonProjectManager } from './internal.api'; import { registerSystemPythonFeatures } from './managers/builtin/main'; import { SysPythonManager } from './managers/builtin/sysPythonManager'; @@ -186,9 +186,6 @@ export async function activate(context: ExtensionContext): Promise { await setEnvironmentCommand(item, envManagers, projectManager); }), - commands.registerCommand('python-envs.reset', async (item) => { - await resetEnvironmentCommand(item, envManagers, projectManager); - }), commands.registerCommand('python-envs.setEnvManager', async () => { await setEnvManagerCommand(envManagers, projectManager); }), @@ -206,7 +203,16 @@ export async function activate(context: ExtensionContext): Promise { - await resetEnvironmentCommand(item, envManagers, projectManager); + // Clear environment association before removing project + if (item instanceof ProjectItem) { + const uri = item.project.uri; + const manager = envManagers.getEnvironmentManager(uri); + if (manager) { + manager.set(uri, undefined); + } else { + traceError(`No environment manager found for ${uri.fsPath}`); + } + } await removePythonProject(item, projectManager); }), commands.registerCommand('python-envs.clearCache', async () => { diff --git a/src/features/envCommands.ts b/src/features/envCommands.ts index 55f0acee..cf375d06 100644 --- a/src/features/envCommands.ts +++ b/src/features/envCommands.ts @@ -329,35 +329,6 @@ async function setEnvironmentForProjects( await em.setEnvironments(uris, environment); } -export async function resetEnvironmentCommand( - context: unknown, - em: EnvironmentManagers, - wm: PythonProjectManager, -): Promise { - if (context instanceof ProjectItem) { - const view = context as ProjectItem; - return resetEnvironmentCommand(view.project.uri, em, wm); - } else if (context instanceof Uri) { - const uri = context as Uri; - const manager = em.getEnvironmentManager(uri); - if (manager) { - manager.set(uri, undefined); - } else { - showErrorMessage(`No environment manager found for: ${uri.fsPath}`); - traceError(`No environment manager found for ${uri.fsPath}`); - } - return; - } else if (context === undefined) { - const pw = await pickProject(wm.getProjects()); - if (pw) { - return resetEnvironmentCommand(pw.uri, em, wm); - } - return; - } - traceError(`Invalid context for unset environment command: ${context}`); - showErrorMessage('Invalid context for unset environment'); -} - export async function setEnvManagerCommand(em: EnvironmentManagers, wm: PythonProjectManager): Promise { const projects = await pickProjectMany(wm.getProjects()); if (projects && projects.length > 0) {