Skip to content

Commit b8f9b1d

Browse files
authored
Add button to open folder from venv failure message (#20243)
Closes #20242 cc/ @cwebster-99
1 parent c78ef06 commit b8f9b1d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/client/common/utils/localize.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export namespace Common {
9797
export const useCommandPrompt = localize('Common.useCommandPrompt', 'Use Command Prompt');
9898
export const download = localize('Common.download', 'Download');
9999
export const showLogs = localize('Common.showLogs', 'Show logs');
100+
export const openFolder = localize('Common.openFolder', 'Open Folder...');
100101
}
101102

102103
export namespace CommonSurvey {
@@ -567,7 +568,7 @@ export namespace CreateEnv {
567568

568569
export const noWorkspace = localize(
569570
'createEnv.noWorkspace',
570-
'Please open a directory when creating an environment using venv.',
571+
'Please open a folder when creating an environment using venv.',
571572
);
572573

573574
export const pickWorkspacePlaceholder = localize(

src/client/pythonEnvironments/creation/common/workspaceSelection.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import * as path from 'path';
66
import { CancellationToken, QuickPickItem, WorkspaceFolder } from 'vscode';
77
import { showErrorMessage, showQuickPick } from '../../../common/vscodeApis/windowApis';
88
import { getWorkspaceFolders } from '../../../common/vscodeApis/workspaceApis';
9-
import { CreateEnv } from '../../../common/utils/localize';
9+
import { Common, CreateEnv } from '../../../common/utils/localize';
10+
import { executeCommand } from '../../../common/vscodeApis/commandApis';
1011

1112
function hasVirtualEnv(workspace: WorkspaceFolder): Promise<boolean> {
1213
return Promise.race([
@@ -39,7 +40,10 @@ export async function pickWorkspaceFolder(
3940
const workspaces = getWorkspaceFolders();
4041

4142
if (!workspaces || workspaces.length === 0) {
42-
showErrorMessage(CreateEnv.noWorkspace);
43+
const result = await showErrorMessage(CreateEnv.noWorkspace, Common.openFolder);
44+
if (result === Common.openFolder) {
45+
await executeCommand('vscode.openFolder');
46+
}
4347
return undefined;
4448
}
4549

0 commit comments

Comments
 (0)