Skip to content

Commit 2ff1423

Browse files
committed
USe create any command from envs ext
1 parent 2d906cb commit 2ff1423

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/client/pythonEnvironments/creation/createEnvApi.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { ConfigurationTarget, Disposable } from 'vscode';
4+
import { ConfigurationTarget, Disposable, QuickInputButtons } from 'vscode';
55
import { Commands } from '../../common/constants';
66
import { IDisposableRegistry, IInterpreterPathService, IPathUtils } from '../../common/types';
77
import { executeCommand, registerCommand } from '../../common/vscodeApis/commandApis';
@@ -21,6 +21,8 @@ import {
2121
import { sendTelemetryEvent } from '../../telemetry';
2222
import { EventName } from '../../telemetry/constants';
2323
import { CreateEnvironmentOptionsInternal } from './types';
24+
import { useEnvExtension } from '../../envExt/api.internal';
25+
import { PythonEnvironment } from '../../envExt/types';
2426

2527
class CreateEnvironmentProviders {
2628
private _createEnvProviders: CreateEnvironmentProvider[] = [];
@@ -65,11 +67,26 @@ export function registerCreateEnvironmentFeatures(
6567
disposables.push(
6668
registerCommand(
6769
Commands.Create_Environment,
68-
(
70+
async (
6971
options?: CreateEnvironmentOptions & CreateEnvironmentOptionsInternal,
7072
): Promise<CreateEnvironmentResult | undefined> => {
71-
const providers = _createEnvironmentProviders.getAll();
72-
return handleCreateEnvironmentCommand(providers, options);
73+
if (useEnvExtension()) {
74+
try {
75+
const result = await executeCommand<PythonEnvironment | undefined>('python-envs.createAny');
76+
if (result) {
77+
return { path: result.environmentPath.path };
78+
}
79+
} catch (err) {
80+
if (err === QuickInputButtons.Back) {
81+
return { workspaceFolder: undefined, action: 'Back' };
82+
}
83+
throw err;
84+
}
85+
} else {
86+
const providers = _createEnvironmentProviders.getAll();
87+
return handleCreateEnvironmentCommand(providers, options);
88+
}
89+
return undefined;
7390
},
7491
),
7592
registerCommand(

0 commit comments

Comments
 (0)