vscode-js-debug
vscode-js-debug copied to clipboard
Copy, store as `temp` and more from hover: allow global `customPropertiesGenerator` for user macros
Is your feature request related to a problem? Please describe.
Hi! First of all, I want to thank you for adding this excellent feature (I'm really not sure what its deprecated), I have already added a lot of macros for general and more specific use. For example, when I go deeply when observing the properties of some object I want to store the value in a temp variable so I can call methods with specific arguments, copy its value, etc...
"customPropertiesGenerator": "function () { return {...this, get _storeAsTemp() { globalThis.temp = this; return true; } }",
It could also be a button to call any function without writing a line in the console:
"customPropertiesGenerator": "function __() { const o = { ...this, get _storeAsTemp() { globalThis.temp = this; return true } }; if(typeof this === 'function' && this.length === 0) Object.defineProperty(o, '__functionResult', { get: () => this.apply(this) }); return o; },
Also, it would be useful to have a way to copy the access path to use it in debugging code later e.g. variable.items[0].text, however, it seems impossible with customPropertiesGenerator
Describe the feature you'd like
Probably add a global vscode setting so I add properties like _storeAsTemp to any configuration I launch, including the Node Terminal.
Also, can I have a few questions regarding this feature?
-
How to make it not show in the variables view? I have tried a few different things but didn't find a solution yet
-
~~I don't understand why it breaks
[[Prototype]]property and why thecopyfunction doesn't work incustomPropertiesGenerator~~ update: example from documentation is misleading you should never use rest syntax...because of getters and prototype
It seems I achieved what I want with another extension, anyway, do you have any plans for customPropertiesGenerator ? This thing seems to be problematic as I didn't find a way to use it with objects instantiated from classes as they can use private properties.
From your issue I don't think that having _storeAsTemp has anything to do with customPropertiesGenerator. Instead we can just have a context menu item to "Store object as global variable" like devtools has.
How to make it not show in the variables view?
There's no such feature. The customPropertiesGenerator allows you to make a custom type that explicitly is used to generate data in the variables view. Everything returned from that will be displayed.