44'use strict' ;
55
66import { inject , injectable } from 'inversify' ;
7- import { Uri } from 'vscode' ;
7+ import { Uri , workspace } from 'vscode' ;
88import { IExtensionSingleActivationService } from '../activation/types' ;
99import { Commands } from '../common/constants' ;
1010import { IDisposable , IDisposableRegistry } from '../common/types' ;
1111import { registerCommand } from '../common/vscodeApis/commandApis' ;
1212import { IInterpreterService } from './contracts' ;
13+ import { useEnvExtension } from '../envExt/api.internal' ;
1314
1415@injectable ( )
1516export class InterpreterPathCommand implements IExtensionSingleActivationService {
@@ -26,7 +27,9 @@ export class InterpreterPathCommand implements IExtensionSingleActivationService
2627 ) ;
2728 }
2829
29- public async _getSelectedInterpreterPath ( args : { workspaceFolder : string } | string [ ] ) : Promise < string > {
30+ public async _getSelectedInterpreterPath (
31+ args : { workspaceFolder : string ; type : string } | string [ ] ,
32+ ) : Promise < string > {
3033 // If `launch.json` is launching this command, `args.workspaceFolder` carries the workspaceFolder
3134 // If `tasks.json` is launching this command, `args[1]` carries the workspaceFolder
3235 let workspaceFolder ;
@@ -35,6 +38,11 @@ export class InterpreterPathCommand implements IExtensionSingleActivationService
3538 } else if ( args [ 1 ] ) {
3639 const [ , second ] = args ;
3740 workspaceFolder = second ;
41+ } else if ( useEnvExtension ( ) && 'type' in args && args . type === 'debugpy' ) {
42+ // If using the envsExt and the type is debugpy, we need to add the workspace folder to get the interpreter path.
43+ if ( Array . isArray ( workspace . workspaceFolders ) && workspace . workspaceFolders . length > 0 ) {
44+ workspaceFolder = workspace . workspaceFolders [ 0 ] . uri . fsPath ;
45+ }
3846 } else {
3947 workspaceFolder = undefined ;
4048 }
0 commit comments