Skip to content

Commit

Permalink
fix: debugAdapterTracker message type error (#939)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricbet authored May 6, 2022
1 parent 6919dca commit 14ce60e
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ export class ExtensionDebugAdapterTracker implements vscode.DebugAdapterTracker
return new ExtensionDebugAdapterTracker(trackers);
}

private toDebugProtocolMessage(message: any): vscode.DebugProtocolMessage {
if (typeof message === 'string') {
try {
return JSON.parse(message);
} catch (error) {}
}
return message;
}

onWillStartSession(): void {
this.trackers.forEach((tracker) => {
if (tracker.onWillStartSession) {
Expand All @@ -33,15 +42,15 @@ export class ExtensionDebugAdapterTracker implements vscode.DebugAdapterTracker
onWillReceiveMessage(message: any): void {
this.trackers.forEach((tracker) => {
if (tracker.onWillReceiveMessage) {
tracker.onWillReceiveMessage(message);
tracker.onWillReceiveMessage(this.toDebugProtocolMessage(message));
}
});
}

onDidSendMessage(message: any): void {
this.trackers.forEach((tracker) => {
if (tracker.onDidSendMessage) {
tracker.onDidSendMessage(message);
tracker.onDidSendMessage(this.toDebugProtocolMessage(message));
}
});
}
Expand Down

0 comments on commit 14ce60e

Please sign in to comment.