Skip to content

Commit dfa7629

Browse files
committed
Fixes Bug where _runOrStopOnEntry could get called multiple times
1 parent 8870164 commit dfa7629

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

src/phpDebug.ts

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,14 @@ class PhpDebugSession extends vscode.DebugSession {
276276
.then(() => Promise.all(args.lines.map(line =>
277277
connection.sendBreakpointSetCommand({type: 'line', fileUri, line})
278278
.then(xdebugResponse => {
279-
// remember that the breakpoints for this connection have been set
280-
this._connectionsAwaitingBreakpoints.delete(connection);
281-
// if this connection has also already received exception breakpoints, run it
282-
if (!this._connectionsAwaitingExceptionBreakpoints.has(connection)) {
283-
this._runOrStopOnEntry(connection);
279+
// has this connection finally received its long-awaited breakpoints?
280+
if (this._connectionsAwaitingBreakpoints.has(connection)) {
281+
// remember that the breakpoints for this connection have been set
282+
this._connectionsAwaitingBreakpoints.delete(connection);
283+
// if this connection has already received exception breakpoints, run it now
284+
if (!this._connectionsAwaitingExceptionBreakpoints.has(connection)) {
285+
this._runOrStopOnEntry(connection);
286+
}
284287
}
285288
// only capture each breakpoint once
286289
if (connectionIndex === 0) {
@@ -331,11 +334,14 @@ class PhpDebugSession extends vscode.DebugSession {
331334
}
332335
})
333336
.then(() => {
334-
// remember that the exception breakpoints for this connection have been set
335-
this._connectionsAwaitingExceptionBreakpoints.delete(connection);
336-
// if this connection has also already received line breakpoints, run it
337-
if (!this._connectionsAwaitingBreakpoints.has(connection)) {
338-
this._runOrStopOnEntry(connection);
337+
// has this connection finally received its long-awaited exception breakpoints?
338+
if (this._connectionsAwaitingExceptionBreakpoints.has(connection)) {
339+
// remember that the exception breakpoints for this connection have been set
340+
this._connectionsAwaitingExceptionBreakpoints.delete(connection);
341+
// if this connection has already received line breakpoints, run it now
342+
if (!this._connectionsAwaitingBreakpoints.has(connection)) {
343+
this._runOrStopOnEntry(connection);
344+
}
339345
}
340346
})
341347
)).then(() => {
@@ -460,6 +466,10 @@ class PhpDebugSession extends vscode.DebugSession {
460466
}
461467

462468
protected continueRequest(response: VSCodeDebugProtocol.ContinueResponse, args: VSCodeDebugProtocol.ContinueArguments): void {
469+
if (!args.threadId) {
470+
this.sendErrorResponse(response, 0, 'No active connection');
471+
return;
472+
}
463473
const connection = this._connections.get(args.threadId);
464474
connection.sendRunCommand()
465475
.then(response => this._checkStatus(response))
@@ -468,6 +478,10 @@ class PhpDebugSession extends vscode.DebugSession {
468478
}
469479

470480
protected nextRequest(response: VSCodeDebugProtocol.NextResponse, args: VSCodeDebugProtocol.NextArguments): void {
481+
if (!args.threadId) {
482+
this.sendErrorResponse(response, 0, 'No active connection');
483+
return;
484+
}
471485
const connection = this._connections.get(args.threadId);
472486
connection.sendStepOverCommand()
473487
.then(response => this._checkStatus(response))
@@ -476,6 +490,10 @@ class PhpDebugSession extends vscode.DebugSession {
476490
}
477491

478492
protected stepInRequest(response: VSCodeDebugProtocol.StepInResponse, args: VSCodeDebugProtocol.StepInArguments) : void {
493+
if (!args.threadId) {
494+
this.sendErrorResponse(response, 0, 'No active connection');
495+
return;
496+
}
479497
const connection = this._connections.get(args.threadId);
480498
connection.sendStepIntoCommand()
481499
.then(response => this._checkStatus(response))
@@ -484,6 +502,10 @@ class PhpDebugSession extends vscode.DebugSession {
484502
}
485503

486504
protected stepOutRequest(response: VSCodeDebugProtocol.StepOutResponse, args: VSCodeDebugProtocol.StepOutArguments) : void {
505+
if (!args.threadId) {
506+
this.sendErrorResponse(response, 0, 'No active connection');
507+
return;
508+
}
487509
const connection = this._connections.get(args.threadId);
488510
connection.sendStepOutCommand()
489511
.then(response => this._checkStatus(response))

0 commit comments

Comments
 (0)