Skip to content
Merged
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
14 changes: 0 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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%",
Expand Down Expand Up @@ -276,10 +270,6 @@
"command": "python-envs.setEnv",
"when": "false"
},
{
"command": "python-envs.reset",
"when": "false"
},
{
"command": "python-envs.remove",
"when": "false"
Expand Down Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 11 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
refreshPackagesCommand,
removeEnvironmentCommand,
removePythonProject,
resetEnvironmentCommand,
runAsTaskCommand,
runInDedicatedTerminalCommand,
runInTerminalCommand,
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -186,9 +186,6 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
commands.registerCommand('python-envs.setEnv', async (item) => {
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);
}),
Expand All @@ -206,7 +203,16 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
await addPythonProjectCommand(resource, projectManager, envManagers, projectCreators);
}),
commands.registerCommand('python-envs.removePythonProject', async (item) => {
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 () => {
Expand Down
29 changes: 0 additions & 29 deletions src/features/envCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,35 +329,6 @@ async function setEnvironmentForProjects(
await em.setEnvironments(uris, environment);
}

export async function resetEnvironmentCommand(
context: unknown,
em: EnvironmentManagers,
wm: PythonProjectManager,
): Promise<void> {
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<void> {
const projects = await pickProjectMany(wm.getProjects());
if (projects && projects.length > 0) {
Expand Down