Skip to content

Commit 690e150

Browse files
Copiloteleanorjboyd
andcommitted
Remove "Reset to Default" command and UI elements
Co-authored-by: eleanorjboyd <[email protected]>
1 parent ecf7b67 commit 690e150

File tree

4 files changed

+15
-48
lines changed

4 files changed

+15
-48
lines changed

package.json

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,7 @@
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-
},
163+
169164
{
170165
"command": "python-envs.remove",
171166
"title": "%python-envs.remove.title%",
@@ -276,10 +271,7 @@
276271
"command": "python-envs.setEnv",
277272
"when": "false"
278273
},
279-
{
280-
"command": "python-envs.reset",
281-
"when": "false"
282-
},
274+
283275
{
284276
"command": "python-envs.remove",
285277
"when": "false"
@@ -401,10 +393,7 @@
401393
"group": "inline",
402394
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
403395
},
404-
{
405-
"command": "python-envs.reset",
406-
"when": "view == python-projects && viewItem =~ /.*python-workspace.*/"
407-
},
396+
408397
{
409398
"command": "python-envs.createTerminal",
410399
"group": "inline",

package.nls.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"python-envs.createAny.title": "Create Environment",
2323
"python-envs.set.title": "Set Project Environment",
2424
"python-envs.setEnv.title": "Set As Project Environment",
25-
"python-envs.reset.title": "Reset to Default",
25+
2626
"python-envs.remove.title": "Delete Environment",
2727
"python-envs.refreshAllManagers.title": "Refresh All Environment Managers",
2828
"python-envs.refreshPackages.title": "Refresh Packages List",

src/extension.ts

Lines changed: 10 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';
@@ -186,9 +186,7 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
186186
commands.registerCommand('python-envs.setEnv', async (item) => {
187187
await setEnvironmentCommand(item, envManagers, projectManager);
188188
}),
189-
commands.registerCommand('python-envs.reset', async (item) => {
190-
await resetEnvironmentCommand(item, envManagers, projectManager);
191-
}),
189+
192190
commands.registerCommand('python-envs.setEnvManager', async () => {
193191
await setEnvManagerCommand(envManagers, projectManager);
194192
}),
@@ -206,7 +204,14 @@ export async function activate(context: ExtensionContext): Promise<PythonEnviron
206204
await addPythonProjectCommand(resource, projectManager, envManagers, projectCreators);
207205
}),
208206
commands.registerCommand('python-envs.removePythonProject', async (item) => {
209-
await resetEnvironmentCommand(item, envManagers, projectManager);
207+
// Clear environment association before removing project
208+
if (item instanceof ProjectItem) {
209+
const uri = item.project.uri;
210+
const manager = envManagers.getEnvironmentManager(uri);
211+
if (manager) {
212+
manager.set(uri, undefined);
213+
}
214+
}
210215
await removePythonProject(item, projectManager);
211216
}),
212217
commands.registerCommand('python-envs.clearCache', async () => {

src/features/envCommands.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -329,34 +329,7 @@ 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-
}
332+
360333

361334
export async function setEnvManagerCommand(em: EnvironmentManagers, wm: PythonProjectManager): Promise<void> {
362335
const projects = await pickProjectMany(wm.getProjects());

0 commit comments

Comments
 (0)