Skip to content

Commit

Permalink
Support terminateThreads.
Browse files Browse the repository at this point in the history
  • Loading branch information
zobo committed Jan 4, 2021
1 parent d8921aa commit 07e6f9c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/phpDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class PhpDebugSession extends vscode.DebugSession {
default: true,
},
],
supportsTerminateThreadsRequest: true,
}
this.sendResponse(response)
}
Expand Down Expand Up @@ -982,6 +983,34 @@ class PhpDebugSession extends vscode.DebugSession {
this.sendErrorResponse(response, new Error('Pausing the execution is not supported by XDebug'))
}

protected async terminateThreadsRequest(
response: VSCodeDebugProtocol.TerminateThreadsResponse,
args: VSCodeDebugProtocol.TerminateThreadsArguments
) {
try {
if (args.threadIds) {
await Promise.all(
args.threadIds.map(async threadId => {
const connection = this._connections.get(threadId)
if (connection) {
await Promise.race([
connection.sendStopCommand(),
new Promise(resolve => setTimeout(resolve, 500)),
])
await connection.close()
this._connections.delete(threadId)
this._waitingConnections.delete(connection)
}
})
)
}
this.sendResponse(response)
} catch (error) {
this.sendErrorResponse(response, error)
return
}
}

protected async disconnectRequest(
response: VSCodeDebugProtocol.DisconnectResponse,
args: VSCodeDebugProtocol.DisconnectArguments
Expand Down

0 comments on commit 07e6f9c

Please sign in to comment.