vscode-js-debug icon indicating copy to clipboard operation
vscode-js-debug copied to clipboard

Copy, store as `temp` and more from hover: allow global `customPropertiesGenerator` for user macros

Open zardoy opened this issue 2 years ago • 2 comments

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; } }",
Screenshot 2023-08-05 at 21 28 50

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 the copy function doesn't work in customPropertiesGenerator~~ update: example from documentation is misleading you should never use rest syntax ... because of getters and prototype

zardoy avatar Aug 05 '23 18:08 zardoy

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.

zardoy avatar Aug 07 '23 16:08 zardoy

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.

connor4312 avatar Aug 17 '23 23:08 connor4312