diff --git a/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts b/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts index 2fa425b..340b815 100644 --- a/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts +++ b/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts @@ -51,6 +51,7 @@ export class GenericEvaluator implements Evaluator { message: { kind: "list", items: [ + "An error occurred while evaluating the expression:", error.message, `Used debug adapter: ${this.session.session.configuration.type}`, { @@ -65,7 +66,9 @@ export class GenericEvaluator implements Evaluator { }; } - return parseEvaluationResultFromGenericDebugAdapter(reply.result); + return parseEvaluationResultFromGenericDebugAdapter(reply.result, { + debugAdapterType: this.session.session.configuration.type, + }); } protected getFinalExpression(args: { @@ -76,6 +79,7 @@ export class GenericEvaluator implements Evaluator { } protected getContext(): "watch" | "repl" { - return "watch"; + // we will use "repl" as default so that results are not truncated. + return "repl"; } } diff --git a/extension/src/EvaluationWatchService/EvaluationEngine/parseEvaluationResultFromGenericDebugAdapter.ts b/extension/src/EvaluationWatchService/EvaluationEngine/parseEvaluationResultFromGenericDebugAdapter.ts index 43d57b2..1df094c 100644 --- a/extension/src/EvaluationWatchService/EvaluationEngine/parseEvaluationResultFromGenericDebugAdapter.ts +++ b/extension/src/EvaluationWatchService/EvaluationEngine/parseEvaluationResultFromGenericDebugAdapter.ts @@ -4,8 +4,13 @@ import { } from "@hediet/debug-visualizer-data-extraction"; import { FormattedMessage } from "../../contract"; +export interface ParseEvaluationResultContext { + debugAdapterType: string; +} + export function parseEvaluationResultFromGenericDebugAdapter( - resultText: string + resultText: string, + context: ParseEvaluationResultContext ): | { kind: "data"; result: DataExtractionResult } | { kind: "error"; message: FormattedMessage } { @@ -26,12 +31,12 @@ export function parseEvaluationResultFromGenericDebugAdapter( // Just in case no quoting is done. jsonData2 = jsonData; } - resultObj = parseJson(jsonData2); + resultObj = parseJson(jsonData2, context); } catch (e) { // in case of C++: `"{ \"kind\": { ... }, \"text\": \"some\\ntext\" }"` - const str = parseJson(jsonData); + const str = parseJson(jsonData, context); // str is now `{ "kind": { ... }, "text": "some\ntext" }"` - resultObj = parseJson(str); + resultObj = parseJson(str, context); // result is now { kind: { ... }, text: "some\ntext" } } @@ -85,7 +90,7 @@ function isEnclosedWith(str: string, char: string): boolean { return str.startsWith(char) && str.endsWith(char); } -function parseJson(str: string) { +function parseJson(str: string, context: ParseEvaluationResultContext) { try { return JSON.parse(str); } catch (error) { @@ -104,6 +109,7 @@ function parseJson(str: string) { }, ], }, + `Used debug adapter: ${context.debugAdapterType}`, ], }); }