@@ -4,10 +4,10 @@ import { debug, window } from "vscode";
44import { StoppedEvent , TerminatedEvent } from "@vscode/debugadapter" ;
55import { VariantEncoder } from "./variables/variant_encoder" ;
66import { VariantDecoder } from "./variables/variant_decoder" ;
7- import { RawObject } from "./variables/variants" ;
7+ import { ObjectId , RawObject } from "./variables/variants" ;
88import { GodotStackFrame , GodotVariable , GodotStackVars } from "../debug_runtime" ;
99import { GodotDebugSession } from "./debug_session" ;
10- import { parse_next_scene_node , split_buffers , build_sub_values } from "./helpers" ;
10+ import { parse_next_scene_node , split_buffers } from "./helpers" ;
1111import { get_configuration , get_free_port , createLogger , verify_godot_version , get_project_version , clean_godot_path } from "../../utils" ;
1212import { prompt_for_godot_executable } from "../../utils/prompts" ;
1313import { subProcess , killSubProcesses } from "../../utils/subspawn" ;
@@ -378,7 +378,7 @@ export class ServerController {
378378 const className : string = command . parameters [ 1 ] ;
379379 const properties : any [ ] = command . parameters [ 2 ] ;
380380
381- // message :inspect_object returns the id as an unsigned 64 bit integer, but it is decoded as a signed 64 bit integer,
381+ // scene :inspect_object returns the id as an unsigned 64 bit integer, but it is decoded as a signed 64 bit integer,
382382 // thus we need to convert it to its equivalent unsigned value here.
383383 if ( id < 0 )
384384 id = id + BigInt ( 2 ) ** BigInt ( 64 ) ;
@@ -388,7 +388,7 @@ export class ServerController {
388388 rawObject . set ( prop [ 0 ] , prop [ 5 ] ) ;
389389 } ) ;
390390 const inspectedVariable = { name : "" , value : rawObject } ;
391- build_sub_values ( inspectedVariable ) ;
391+ this . build_sub_values ( inspectedVariable ) ;
392392 if ( this . session . inspect_callbacks . has ( BigInt ( id ) ) ) {
393393 this . session . inspect_callbacks . get ( BigInt ( id ) ) (
394394 inspectedVariable . name ,
@@ -416,8 +416,12 @@ export class ServerController {
416416 break ;
417417 }
418418 case "stack_frame_vars" : {
419- this . partialStackVars . reset ( command . parameters [ 0 ] ) ;
420- this . session . set_scopes ( this . partialStackVars ) ;
419+ const stack_var_count = command . parameters [ 0 ] ;
420+ this . partialStackVars . reset ( stack_var_count ) ;
421+
422+ if ( stack_var_count <= 0 )
423+ this . session . set_scopes ( this . partialStackVars ) ;
424+
421425 break ;
422426 }
423427 case "stack_frame_var" : {
@@ -556,7 +560,7 @@ export class ServerController {
556560 }
557561
558562 const variable : GodotVariable = { name, value, type } ;
559- build_sub_values ( variable ) ;
563+ this . build_sub_values ( variable ) ;
560564
561565 const scopeName = [ "locals" , "members" , "globals" ] [ scope ] ;
562566 this . partialStackVars [ scopeName ] . push ( variable ) ;
@@ -566,4 +570,64 @@ export class ServerController {
566570 this . session . set_scopes ( this . partialStackVars ) ;
567571 }
568572 }
573+
574+ private build_sub_values ( va : GodotVariable ) {
575+ const value = va . value ;
576+
577+ let subValues : GodotVariable [ ] = undefined ;
578+
579+ if ( value && Array . isArray ( value ) ) {
580+ subValues = value . map ( ( va , i ) => {
581+ const gd_var = {
582+ name : `${ i } ` ,
583+ value : va ,
584+ } as GodotVariable ;
585+
586+ if ( gd_var . value instanceof ObjectId )
587+ this . session . add_to_inspections ( [ gd_var ] ) ;
588+
589+ return gd_var ;
590+ } ) ;
591+ } else if ( value instanceof Map ) {
592+ subValues = Array . from ( value . keys ( ) ) . map ( ( va ) => {
593+ if ( typeof va [ "stringify_value" ] === "function" ) {
594+ const gd_var = {
595+ name : `${ va . type_name ( ) } ${ va . stringify_value ( ) } ` ,
596+ value : value . get ( va ) ,
597+ } as GodotVariable ;
598+
599+ if ( gd_var . value instanceof ObjectId )
600+ this . session . add_to_inspections ( [ gd_var ] ) ;
601+
602+ return gd_var ;
603+ } else {
604+ const gd_var = {
605+ name : `${ va } ` ,
606+ value : value . get ( va ) ,
607+ } as GodotVariable ;
608+
609+ if ( gd_var . value instanceof ObjectId )
610+ this . session . add_to_inspections ( [ gd_var ] ) ;
611+
612+ return gd_var ;
613+ }
614+ } ) ;
615+ } else if ( value && typeof value [ "sub_values" ] === "function" ) {
616+ subValues = value . sub_values ( ) . map ( ( sva ) => {
617+ const gd_var = {
618+ name : sva . name ,
619+ value : sva . value ,
620+ } as GodotVariable ;
621+
622+ if ( gd_var . value instanceof ObjectId )
623+ this . session . add_to_inspections ( [ gd_var ] ) ;
624+
625+ return gd_var ;
626+ } ) ;
627+ }
628+
629+ va . sub_values = subValues ;
630+
631+ subValues ?. forEach ( this . build_sub_values . bind ( this ) ) ;
632+ }
569633}
0 commit comments