diff --git a/service/dap/server.go b/service/dap/server.go index 8c9dc341..62dd14d9 100644 --- a/service/dap/server.go +++ b/service/dap/server.go @@ -962,7 +962,21 @@ func (s *Server) convertVariable(v *proc.Variable) (value string, variablesRefer } else if len(v.Children) == 0 || v.Children[0].Kind == reflect.Invalid && v.Children[0].Addr == 0 { value = "nil <" + typeName + ">" } else { - value = "<" + typeName + ">" + value = "<" + typeName + "(" + v.Children[0].TypeString() + ")" + ">" + // TODO(polina): should we remove one level of indirection and skip "data"? + // Then we will have: + // Before: + // i: + // data: 123 + // After: + // i: 123 + // Before: + // i: + // data: + // field1: ... + // After: + // i: + // field1: ... variablesReference = s.variableHandles.create(v) } case reflect.Complex64, reflect.Complex128: diff --git a/service/dap/server_test.go b/service/dap/server_test.go index fb870627..b2a82d04 100644 --- a/service/dap/server_test.go +++ b/service/dap/server_test.go @@ -909,14 +909,14 @@ func TestScopesAndVariablesRequests2(t *testing.T) { expectVarExact(t, locals, -1, "fn2", "", noChildren) // reflect.Kind == Interface expectVarExact(t, locals, -1, "ifacenil", "nil ", noChildren) - ref = expectVarExact(t, locals, -1, "iface2", "", hasChildren) + ref = expectVarExact(t, locals, -1, "iface2", "", hasChildren) if ref > 0 { client.VariablesRequest(ref) iface2 := client.ExpectVariablesResponse(t) expectChildren(t, iface2, "iface2", 1) expectVarExact(t, iface2, 0, "data", `"test"`, noChildren) } - ref = expectVarExact(t, locals, -1, "iface4", "", hasChildren) + ref = expectVarExact(t, locals, -1, "iface4", "", hasChildren) if ref > 0 { client.VariablesRequest(ref) iface4 := client.ExpectVariablesResponse(t) @@ -926,10 +926,12 @@ func TestScopesAndVariablesRequests2(t *testing.T) { client.VariablesRequest(ref) iface4data := client.ExpectVariablesResponse(t) expectChildren(t, iface4data, "iface4.data", 1) - expectVarExact(t, iface4data, 0, "[0]", "", hasChildren) + expectVarExact(t, iface4data, 0, "[0]", "", hasChildren) } } + expectVarExact(t, locals, -1, "errnil", "nil ", noChildren) + expectVarExact(t, locals, -1, "err1", "", hasChildren) // reflect.Kind == Map expectVarExact(t, locals, -1, "mnil", "nil ", noChildren) ref = expectVarExact(t, locals, -1, "m2", " (length: 1)", hasChildren)