Skip to content
Merged
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
22 changes: 14 additions & 8 deletions src/features/envCommands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QuickInputButtons, TaskExecution, TaskRevealKind, Terminal, Uri } from 'vscode';
import { commands, QuickInputButtons, TaskExecution, TaskRevealKind, Terminal, Uri } from 'vscode';
import {
CreateEnvironmentOptions,
PythonEnvironment,
Expand Down Expand Up @@ -59,9 +59,7 @@ export async function refreshPackagesCommand(context: unknown, managers?: Enviro
} else if (context instanceof PythonEnvTreeItem) {
const view = context as PythonEnvTreeItem;
const envManager =
view.parent.kind === EnvTreeItemKind.environmentGroup
? view.parent.parent.manager
: view.parent.manager;
view.parent.kind === EnvTreeItemKind.environmentGroup ? view.parent.parent.manager : view.parent.manager;
const pkgManager = managers?.getPackageManager(envManager.preferredPackageManagerId);
if (pkgManager) {
await pkgManager.refresh(view.environment);
Expand Down Expand Up @@ -205,8 +203,7 @@ export async function removeEnvironmentCommand(context: unknown, managers: Envir
export async function handlePackageUninstall(context: unknown, em: EnvironmentManagers) {
if (context instanceof PackageTreeItem || context instanceof ProjectPackage) {
const moduleName = context.pkg.name;
const environment =
context instanceof ProjectPackage ? context.parent.environment : context.parent.environment;
const environment = context instanceof ProjectPackage ? context.parent.environment : context.parent.environment;
const packageManager = em.getPackageManager(environment);
await packageManager?.manage(environment, { uninstall: [moduleName], install: [] });
return;
Expand Down Expand Up @@ -395,8 +392,17 @@ export async function addPythonProjectCommand(
pc: ProjectCreators,
): Promise<void> {
if (wm.getProjects().length === 0) {
showErrorMessage('Please open a folder/project before adding a workspace');
return;
const r = await showErrorMessage(
'Please open a folder/project to create a Python project.',
{
modal: true,
},
'Open Folder',
);
if (r === 'Open Folder') {
await commands.executeCommand('vscode.openFolder');
return;
}
}
if (resource instanceof Array) {
for (const r of resource) {
Expand Down