Skip to content

Commit b6e341e

Browse files
committed
add workspace folder for debugpy launch.json config
1 parent ba56b21 commit b6e341e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/client/interpreter/interpreterPathCommand.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
'use strict';
55

66
import { inject, injectable } from 'inversify';
7-
import { Uri } from 'vscode';
7+
import { Uri, workspace } from 'vscode';
88
import { IExtensionSingleActivationService } from '../activation/types';
99
import { Commands } from '../common/constants';
1010
import { IDisposable, IDisposableRegistry } from '../common/types';
1111
import { registerCommand } from '../common/vscodeApis/commandApis';
1212
import { IInterpreterService } from './contracts';
13+
import { useEnvExtension } from '../envExt/api.internal';
1314

1415
@injectable()
1516
export 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

Comments
 (0)