Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add button to open folder from venv failure message #20243

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export namespace Common {
export const useCommandPrompt = localize('Common.useCommandPrompt', 'Use Command Prompt');
export const download = localize('Common.download', 'Download');
export const showLogs = localize('Common.showLogs', 'Show logs');
export const openFolder = localize('Common.openFolder', 'Open Folder...');
}

export namespace CommonSurvey {
Expand Down Expand Up @@ -563,7 +564,7 @@ export namespace CreateEnv {

export const noWorkspace = localize(
'createEnv.noWorkspace',
'Please open a directory when creating an environment using venv.',
'Please open a folder when creating an environment using venv.',
);

export const pickWorkspacePlaceholder = localize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import * as path from 'path';
import { CancellationToken, QuickPickItem, WorkspaceFolder } from 'vscode';
import { showErrorMessage, showQuickPick } from '../../../common/vscodeApis/windowApis';
import { getWorkspaceFolders } from '../../../common/vscodeApis/workspaceApis';
import { CreateEnv } from '../../../common/utils/localize';
import { Common, CreateEnv } from '../../../common/utils/localize';
import { executeCommand } from '../../../common/vscodeApis/commandApis';

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

if (!workspaces || workspaces.length === 0) {
showErrorMessage(CreateEnv.noWorkspace);
const result = await showErrorMessage(CreateEnv.noWorkspace, Common.openFolder);
if (result === Common.openFolder) {
await executeCommand('vscode.openFolder');
}
return undefined;
}

Expand Down