Skip to content

Commit fddedda

Browse files
committed
fix #518
1 parent 238d034 commit fddedda

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/client/debugger/Main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export class PythonDebugger extends DebugSession {
8282

8383
private startDebugServer(): Promise<IDebugServer> {
8484
let programDirectory = this.launchArgs ? path.dirname(this.launchArgs.program) : this.attachArgs.localRoot;
85+
if (typeof this.launchArgs.cwd === 'string' && this.launchArgs.cwd.length > 0) {
86+
programDirectory = this.launchArgs.cwd;
87+
}
8588
this.pythonProcess = new PythonProcess(0, "", programDirectory);
8689
this.debugServer = this.debugClient.CreateDebugServer(this.pythonProcess);
8790
this.InitializeEventHandlers();
@@ -178,8 +181,16 @@ export class PythonDebugger extends DebugSession {
178181
}
179182
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
180183
// Confirm the file exists
181-
if (!fs.existsSync(args.program)) {
182-
return this.sendErrorResponse(response, 2001, `File does not exist. "${args.program}"`);
184+
if (typeof args.module !== 'string' || args.module.length === 0) {
185+
if (!fs.existsSync(args.program)) {
186+
return this.sendErrorResponse(response, 2001, `File does not exist. "${args.program}"`);
187+
}
188+
}
189+
else {
190+
// When using modules ensure the cwd has been provided
191+
if (typeof args.cwd !== 'string' || args.cwd.length === 0){
192+
return this.sendErrorResponse(response, 2001, `'cwd' in 'launch.json' needs to point to the working directory`);
193+
}
183194
}
184195
this.sendEvent(new TelemetryEvent(telemetryContracts.Debugger.Load, {
185196
Debug_Console: args.console,

0 commit comments

Comments
 (0)