From 0ae2541f8d90b4816fbe1f49538745617011b879 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Tue, 24 Jun 2025 15:08:43 -0700 Subject: [PATCH] feat: open parent folder of venv after creation --- src/managers/builtin/venvManager.ts | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/managers/builtin/venvManager.ts b/src/managers/builtin/venvManager.ts index c1464d87..e655f6a9 100644 --- a/src/managers/builtin/venvManager.ts +++ b/src/managers/builtin/venvManager.ts @@ -1,6 +1,15 @@ import * as fs from 'fs/promises'; import * as path from 'path'; -import { EventEmitter, l10n, LogOutputChannel, MarkdownString, ProgressLocation, ThemeIcon, Uri } from 'vscode'; +import { + commands, + EventEmitter, + l10n, + LogOutputChannel, + MarkdownString, + ProgressLocation, + ThemeIcon, + Uri, +} from 'vscode'; import { CreateEnvironmentOptions, CreateEnvironmentScope, @@ -162,6 +171,7 @@ export class VenvManager implements EnvironmentManager { showQuickAndCustomOptions: options?.quickCreate === undefined, }); } + if (environment) { this.addEnvironment(environment, true); @@ -175,6 +185,21 @@ export class VenvManager implements EnvironmentManager { `Failed to create .gitignore in venv: ${err instanceof Error ? err.message : String(err)}`, ); } + + // Open the parent folder of the venv in the current window immediately after creation + const envParent = path.dirname(environment.sysPrefix); + try { + await commands.executeCommand('vscode.openFolder', Uri.file(envParent), { + forceNewWindow: false, + }); + } catch (error) { + showErrorMessage( + l10n.t('Failed to open venv parent folder: but venv was still created in {0}', envParent), + ); + traceError( + `Failed to open venv parent folder: ${error instanceof Error ? error.message : String(error)}`, + ); + } } return environment; } finally {