-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Debug console in NodeJs does not display value returned via util.inspect.custom or toString #46829
Comments
Calling util.inspect to generate the preview when the object has overridden util.inspect.custom is a good idea. I don't think we want to use it for every preview. Our preview should give a short high level view of the properties of an object, but util.inspect recurses and writes out every property of the object, and returns a multiline string where in the debug console, we can only show a single line. |
@roblourens - anyway to override that one line would be great... I was not sure about inspect either. Maybe hooking on a toString() method if it exists would work better? I think that is the way it works in .NET + VisualStudio. |
Also looking for a solution. As a Python turned TypeScript dev, I'm sorely missing Python's Perhaps a setting in VS Code that allow VSCode to call the toString method on an object to display in that one line? |
please see the related item #26234 which we plan to investigate in the August timeframe. |
I believe this works fine with latest vscode insiders. |
@connor4312 our investigation in #26234 showed that Custom Object Formatters need to be implemented by individual debug extensions. Therefore I'm reopening this issue for JavaScript. Maybe you have already some insights in this topic... |
Thanks for the tag. Merging this into #102181 which is being revivified by backlog issues. |
Environment details
Steps to Reproduce
Actual
This is displayed
Expected
In my opinion, this is not quite right. The inspect method is invoked as you would expect but the debug textual representation for the object instance is not shown to be the custom return string value.
Ideally, I believe the debug console should show the summary value of the object as:
SomeObject { "custom textual rapresentation of my object" }
while still providing the ability to drill down into the object (as it already does).Additional Info
This started as a question on StackOverflow: https://stackoverflow.com/questions/49365663/how-to-change-string-representation-of-objects-in-nodejs-debug-console-view
The text was updated successfully, but these errors were encountered: