Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Show toString of Objects In Hover #1284

Closed
hediet opened this issue May 25, 2022 · 7 comments · Fixed by #1296
Closed

Feature Request: Show toString of Objects In Hover #1284

hediet opened this issue May 25, 2022 · 7 comments · Fixed by #1296
Assignees
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@hediet
Copy link
Member

hediet commented May 25, 2022

It would be really helpful if the hover title would show the .toString() result of the object:

image

In this case, .toString() of the range would be [3,3).

v8 allows you to call a function (such as .toString()) but throw before any side-effect is caused.

@hediet hediet added the feature-request Request for new features or functionality label May 25, 2022
@connor4312 connor4312 added this to the June 2022 milestone Jun 7, 2022
@connor4312
Copy link
Member

connor4312 commented Jun 7, 2022

My instinct would be to use toString() in place of where we currently show { startLineNumber: 3, lineCount: 0 }. This is the same code that runs to show the preview in the VARIABLES view, too.

The difficult part is that we build that preview off of the information we get by calling getProperties on the scope (or the parent object -- both are "runtime objects"), which looks like this for an instance of a class that implements toString()

{
  "type": "object",
  "className": "Foo",
  "description": "Foo",
  "objectId": "-4497892529713776404.1.30",
  "preview": {
    "type": "object",
    "description": "Foo",
    "overflow": false,
    "properties": [
      {
        "name": "hello",
        "type": "string",
        "value": "world"
      }
    ]
  }
}

Unfortunately there's no indication that there is a toString() there (since it's on the prototype of that object. So, we'd have to actually evaluate code separately to determine what the preview should be. If we do this in a scope where there's a ton of variables, that's a ton of extra evaluations we make.

While I'm not enthused about introducing discrepancy between display in the hover and variables view, we could special case the hover evaluation to do something special and call toString() only for the top level object -- would that still be useful?

@hediet
Copy link
Member Author

hediet commented Jun 8, 2022

would that still be useful?

Yes, but having it everywhere would be even more useful.

@connor4312
Copy link
Member

Figured out a way to make it work everywhere pretty well

@connor4312
Copy link
Member

@hediet I think you can verify

@hediet hediet added the verified Verification succeeded label Jun 28, 2022
@hediet
Copy link
Member Author

hediet commented Jun 28, 2022

Use it almost daily. A great feature!!

@liuxilu
Copy link

liuxilu commented Nov 8, 2022

NOT a debugging viewer WITHOUT this function!!!
It's long-requested in fact, but people hardly find the repo of a built-in/shipped-with function other than vscode's where such issue will be said 'go to the debugger repo!'
microsoft/vscode#26234 microsoft/vscode#38273

@connor4312
Copy link
Member

Not sure what you're asking...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants