Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support terminateThreads #366

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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