From 14ce60efeeca82919f2e4712d75f7d7d8c0b3229 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 6 May 2022 10:40:27 +0800 Subject: [PATCH] fix: debugAdapterTracker message type error (#939) --- .../vscode/debug/extension-debug-adapter-tracker.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/extension/src/hosted/api/vscode/debug/extension-debug-adapter-tracker.ts b/packages/extension/src/hosted/api/vscode/debug/extension-debug-adapter-tracker.ts index 8893006521..92a90cd6f7 100644 --- a/packages/extension/src/hosted/api/vscode/debug/extension-debug-adapter-tracker.ts +++ b/packages/extension/src/hosted/api/vscode/debug/extension-debug-adapter-tracker.ts @@ -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) { @@ -33,7 +42,7 @@ 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)); } }); } @@ -41,7 +50,7 @@ export class ExtensionDebugAdapterTracker implements vscode.DebugAdapterTracker onDidSendMessage(message: any): void { this.trackers.forEach((tracker) => { if (tracker.onDidSendMessage) { - tracker.onDidSendMessage(message); + tracker.onDidSendMessage(this.toDebugProtocolMessage(message)); } }); }