File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,10 +100,16 @@ function variable.fetch_children(var, cb)
100100 elseif resp then
101101 local variables = resp .variables
102102 local unloaded = # variables
103+ var .variables = variables
104+
105+ if unloaded == 0 then
106+ cb (variables )
107+ return
108+ end
109+
103110 local function countdown ()
104111 unloaded = unloaded - 1
105112 if unloaded == 0 then
106- var .variables = variables
107113 cb (variables )
108114 end
109115 end
Original file line number Diff line number Diff line change 1+ local dap = require (' dap' )
2+ local helpers = require (" spec.helpers" )
3+
4+ local config = {
5+ type = ' dummy' ,
6+ request = ' launch' ,
7+ name = ' Launch file' ,
8+ }
9+
10+
11+ describe (" variable entity" , function ()
12+ local server
13+ before_each (function ()
14+ server = require (' spec.server' ).spawn ()
15+ dap .adapters .dummy = server .adapter
16+ end )
17+ after_each (function ()
18+ server .stop ()
19+ dap .close ()
20+ helpers .wait (function () return dap .session () == nil end , " session should become nil" )
21+ end )
22+
23+ it (" fetch_children triggers callback on empty variables" , function ()
24+ server .client .variables = function (self , request )
25+ self :send_response (request , {
26+ variables = {}
27+ })
28+ end
29+ helpers .run_and_wait_until_initialized (config , server )
30+ local variable = require (" dap.entity" ).variable
31+
32+ local var = {
33+ name = " x" ,
34+ value = 1 ,
35+ variablesReference = 1 ,
36+ }
37+ local variables = nil
38+ variable .fetch_children (var , function (vars )
39+ variables = vars
40+ end )
41+
42+ helpers .wait (function () return variables ~= nil end , " must call callback with variables" )
43+ assert .are .same ({}, variables )
44+ end )
45+ end )
You can’t perform that action at this time.
0 commit comments