diff --git a/service/dap/server.go b/service/dap/server.go index 7da8b033..aef2f90d 100644 --- a/service/dap/server.go +++ b/service/dap/server.go @@ -2045,6 +2045,9 @@ func (s *Server) convertVariableWithOpts(v *proc.Variable, qualifiedNameOrExpr s variablesReference = maybeCreateVariableHandle(v) } } + + // By default, only values of variables that have children can be truncated. + // If showFullValue is set, then all value strings are not truncated. canTruncateValue := showFullValue&opts == 0 if len(value) > defaultMaxValueLen && canTruncateValue && canHaveRef { value = value[:defaultMaxValueLen] + "..." @@ -2123,7 +2126,9 @@ func (s *Server) onEvaluateRequest(request *dap.EvaluateRequest) { } } var opts convertVariableFlags - if ctxt == "variables" || ctxt == "hover" || ctxt == "clipboard" { + // Send the full value when the context is "clipboard" or "variables" since + // these contexts are used to copy the value. + if ctxt == "clipboard" || ctxt == "variables" { opts |= showFullValue } exprVal, exprRef := s.convertVariableWithOpts(exprVar, fmt.Sprintf("(%s)", request.Arguments.Expression), opts) diff --git a/service/dap/server_test.go b/service/dap/server_test.go index a027ba35..45e08f91 100644 --- a/service/dap/server_test.go +++ b/service/dap/server_test.go @@ -2883,7 +2883,7 @@ func TestEvaluateRequestLongStrLargeValue(t *testing.T) { got3 := client.ExpectEvaluateResponse(t) want3 := m1Truncated switch evalContext { - case "variables", "hover", "clipboard": + case "variables", "clipboard": want3 = m1 } checkEvalRegex(t, got3, want3, true)