|
1 | | -import { QuickInputButtons, TaskExecution, TaskRevealKind, Terminal, Uri } from 'vscode'; |
| 1 | +import { commands, QuickInputButtons, TaskExecution, TaskRevealKind, Terminal, Uri } from 'vscode'; |
2 | 2 | import { |
3 | 3 | CreateEnvironmentOptions, |
4 | 4 | PythonEnvironment, |
@@ -59,9 +59,7 @@ export async function refreshPackagesCommand(context: unknown, managers?: Enviro |
59 | 59 | } else if (context instanceof PythonEnvTreeItem) { |
60 | 60 | const view = context as PythonEnvTreeItem; |
61 | 61 | const envManager = |
62 | | - view.parent.kind === EnvTreeItemKind.environmentGroup |
63 | | - ? view.parent.parent.manager |
64 | | - : view.parent.manager; |
| 62 | + view.parent.kind === EnvTreeItemKind.environmentGroup ? view.parent.parent.manager : view.parent.manager; |
65 | 63 | const pkgManager = managers?.getPackageManager(envManager.preferredPackageManagerId); |
66 | 64 | if (pkgManager) { |
67 | 65 | await pkgManager.refresh(view.environment); |
@@ -205,8 +203,7 @@ export async function removeEnvironmentCommand(context: unknown, managers: Envir |
205 | 203 | export async function handlePackageUninstall(context: unknown, em: EnvironmentManagers) { |
206 | 204 | if (context instanceof PackageTreeItem || context instanceof ProjectPackage) { |
207 | 205 | const moduleName = context.pkg.name; |
208 | | - const environment = |
209 | | - context instanceof ProjectPackage ? context.parent.environment : context.parent.environment; |
| 206 | + const environment = context instanceof ProjectPackage ? context.parent.environment : context.parent.environment; |
210 | 207 | const packageManager = em.getPackageManager(environment); |
211 | 208 | await packageManager?.manage(environment, { uninstall: [moduleName], install: [] }); |
212 | 209 | return; |
@@ -395,8 +392,17 @@ export async function addPythonProjectCommand( |
395 | 392 | pc: ProjectCreators, |
396 | 393 | ): Promise<void> { |
397 | 394 | if (wm.getProjects().length === 0) { |
398 | | - showErrorMessage('Please open a folder/project before adding a workspace'); |
399 | | - return; |
| 395 | + const r = await showErrorMessage( |
| 396 | + 'Please open a folder/project to create a Python project.', |
| 397 | + { |
| 398 | + modal: true, |
| 399 | + }, |
| 400 | + 'Open Folder', |
| 401 | + ); |
| 402 | + if (r === 'Open Folder') { |
| 403 | + await commands.executeCommand('vscode.openFolder'); |
| 404 | + return; |
| 405 | + } |
400 | 406 | } |
401 | 407 | if (resource instanceof Array) { |
402 | 408 | for (const r of resource) { |
|
0 commit comments