Skip to content

Commit

Permalink
Fix edge case for falsy values
Browse files Browse the repository at this point in the history
  • Loading branch information
amomchilov committed Jan 4, 2024
1 parent eca9d80 commit b24af44
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/debug/server_cdp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,9 @@ def process_cdp args
when :properties
oid = args.shift

if obj = @obj_map[oid]
if @obj_map.key?(oid)
obj = @obj_map[oid]

members = if Array === obj
VariableInspector.new.indexed_members_of(obj, start: 0, count: obj.size)
else
Expand Down
6 changes: 4 additions & 2 deletions lib/debug/server_dap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,10 @@ def process_dap args
event! :protocol_result, :scope, req, variables: vars, tid: self.id
when :variable
vid = args.shift
obj = @var_map[vid]
if obj

if @var_map.key?(vid)
obj = @var_map[vid]

members = case req.dig('arguments', 'filter')
when 'indexed'
VariableInspector.new.indexed_members_of(
Expand Down
6 changes: 3 additions & 3 deletions test/protocol/step_back_raw_dap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ def test_step_back_works_correctly
namedVariables: /\d+/,
indexedVariables: 0,
expensive: false,
variablesReference: 11
variablesReference: 12
},
{
name: "Global variables",
Expand Down Expand Up @@ -917,15 +917,15 @@ def test_step_back_works_correctly
name: "%self",
value: "Foo",
type: "Module",
variablesReference: 12,
variablesReference: 13,
indexedVariables: 0,
namedVariables: /\d+/
},
{
name: "bar",
value: "nil",
type: "NilClass",
variablesReference: 13,
variablesReference: 14,
indexedVariables: 0,
namedVariables: /\d+/
}
Expand Down

0 comments on commit b24af44

Please sign in to comment.