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

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

Open
zardoy opened this issue Aug 5, 2023 · 2 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@zardoy
Copy link
Contributor

zardoy commented Aug 5, 2023

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 zardoy added the feature-request Request for new features or functionality label Aug 5, 2023
@zardoy
Copy link
Contributor Author

zardoy commented Aug 7, 2023

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.

@connor4312
Copy link
Member

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.

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
Projects
None yet
Development

No branches or pull requests

2 participants