Skip to content

Commit

Permalink
Fixes stopped indicator when performing stop or continue.
Browse files Browse the repository at this point in the history
When the IDE requests a continue operation (step in, out, over, continue) it expects a Response and will remove the current execution position. With XDebug/DBGp the TCP connection will not send a response until another stop condition is encountered this may take an arbitrary amount of time.
This change fixes this by doing some basic validation (is the threadId valid) and then sends a response before executing the continuation command.

Closes #358
  • Loading branch information
zobo committed Jan 2, 2021
1 parent d8921aa commit 37124d4
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/phpDebug.ts
Expand Up @@ -898,20 +898,19 @@ class PhpDebugSession extends vscode.DebugSession {
try {
const connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
response.body = {
allThreadsContinued: false,
}
this.sendResponse(response)
xdebugResponse = await connection.sendRunCommand()
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
response.body = {
allThreadsContinued: false,
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
}

Expand All @@ -920,17 +919,16 @@ class PhpDebugSession extends vscode.DebugSession {
try {
const connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
this.sendResponse(response)
xdebugResponse = await connection.sendStepOverCommand()
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
}

Expand All @@ -942,17 +940,16 @@ class PhpDebugSession extends vscode.DebugSession {
try {
const connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
this.sendResponse(response)
xdebugResponse = await connection.sendStepIntoCommand()
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
}

Expand All @@ -964,17 +961,16 @@ class PhpDebugSession extends vscode.DebugSession {
try {
const connection = this._connections.get(args.threadId)
if (!connection) {
throw new Error('Unknown thread ID ' + args.threadId)
return this.sendErrorResponse(response, new Error('Unknown thread ID ' + args.threadId))
}
this.sendResponse(response)
xdebugResponse = await connection.sendStepOutCommand()
} catch (error) {
this.sendErrorResponse(response, error)
if (xdebugResponse) {
this._checkStatus(xdebugResponse)
}
return
}
this.sendResponse(response)
this._checkStatus(xdebugResponse)
}

Expand Down

0 comments on commit 37124d4

Please sign in to comment.