From 3e0a427decb44ccc08049ab93044d5772c1df11b Mon Sep 17 00:00:00 2001 From: keithcat1 Date: Mon, 24 Oct 2022 15:04:20 -0500 Subject: [PATCH] Typing the name of a variable / function will now print its value instead of nothing. Fixes #47. --- packages/interactive/lib/src/executor.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/interactive/lib/src/executor.dart b/packages/interactive/lib/src/executor.dart index 2366d23..1488213 100644 --- a/packages/interactive/lib/src/executor.dart +++ b/packages/interactive/lib/src/executor.dart @@ -83,9 +83,12 @@ class Executor { log.info('Phase: Evaluate'); final isolateInfo = await workspaceIsolate.isolateInfo; final targetId = isolateInfo.rootLib!.id!; - final response = await vm.vmService + Response response = await vm.vmService .evaluate(workspaceIsolate.isolateId, targetId, _evaluateCode); - + if(response is InstanceRef && response.valueAsString == null) { + // InstanceRef.valueAsString only works on primitive values like String, int, double ETC, so for anything else we have to ask the VM to get the toString value + response = await vm.vmService.evaluate(workspaceIsolate.isolateId, response.id!, "this.toString()"); + } _handleEvaluateResponse(response); }