Skip to content

Fix preview rendering of number '0' when 'description' is not set. #1967

@Beanyy

Description

@Beanyy

Describe the bug
Some Javascript Debuggee CDP implementations (Hermes) return the a RemoteObject of type=number , value=0 and the description and unserializableValue fields unset. This causes RemoteObjects with type=number and value=0 to be rendered as NaN due to the logic of formatting numbers here:

if (param.type === 'number') {
if ('unserializableValue' in param) {
return param.unserializableValue;
}
const value = param.value || +param.description;
return format?.hex ? value.toString(16) : String(value);
}

If param.value is falsy (as is for zero), it uses the description, but if that is unset it will display NaN.
I'm suggesting making an explicit check for positive zero here and assigniing it to value if the description is not set.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Log File

VS Code Version: Replace me!

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

Labels

bugIssue identified by VS Code Team member as probable bughelp welcomeIssues identified as good community contribution opportunitiesverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions