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' ;
55import { Commands } from '../../common/constants' ;
66import { IDisposableRegistry , IInterpreterPathService , IPathUtils } from '../../common/types' ;
77import { executeCommand , registerCommand } from '../../common/vscodeApis/commandApis' ;
@@ -21,6 +21,8 @@ import {
2121import { sendTelemetryEvent } from '../../telemetry' ;
2222import { EventName } from '../../telemetry/constants' ;
2323import { CreateEnvironmentOptionsInternal } from './types' ;
24+ import { useEnvExtension } from '../../envExt/api.internal' ;
25+ import { PythonEnvironment } from '../../envExt/types' ;
2426
2527class 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