mylesmmurphy / prettify-ts

Prettify TypeScript: Better Type Previews
https://marketplace.visualstudio.com/items?itemName=MylesMurphy.prettify-ts
MIT License
203 stars 6 forks source link

[Request] - Toggle hotkey #32

Open salmin89 opened 4 weeks ago

salmin89 commented 4 weeks ago

Hey, I've been using your extension for a while now and what I've noticed that I end up doing a lot is disabling the extension whenever the expanded type is too large.

Without the extension I can hold CMD and hover a variable and sometimes I'll get some type insight, so I was wondering if you could add a feature like that? maybe a way to manually show/hide expanded types based on hotkey

ismailkarsli commented 3 weeks ago

Same. It would be great to use the plugin optionally with a modifier key.

mylesmmurphy commented 3 weeks ago

Hey @salmin89 and @ismailkarsli! Thanks for your feedback.

Handling how to display large types has been a continuous struggle which I’m trying to improve with each update. Currently I am working on improving nested types that have non-aliased sub properties, which currently are displayed even if your depth setting indicates they shouldn’t be. If possible, would you mind sharing the type that is displayed that’s too large, and what the resulting type preview from the extension is? I am hopeful my current changes for the next release address it address it already.

Also - Having you explored restricting the settings of the extension to display less properties, or truncate the max number of characters?

Regarding a hotkey to enable/disable, unfortunately VSCode does not expose an API to check for key presses the same way the default setting does to expand on types, but one option I could explore is creating a command for the extension to enable / disable, which then it might be possible to attach a key-bind to trigger that toggle command. Would that be acceptable in your case?

Thanks for using my extension and for your feedback! 😁

ismailkarsli commented 3 weeks ago

I just checked and there are many options in extension settings as you're saying. However, sometimes I need to see the class names and their wrappers rather than the object structure. For example;

In other words, things that are not pure objects.

Toggling the feature without enabling/disabling the plugin would be enough for me.

I really appreciate this plugin by the way. I was thinking of making the same plugin and was glad to see that it was already done :)

salmin89 commented 3 weeks ago

I haven’t messed around with the max props and depth settings. I’ll definitely test changing those!

otherwise I’d be totally fine with a hot key as mentioned 🙂

alythobani commented 5 days ago

Thanks for this extension, I was going to make a similar one a while back until I saw you'd make this already! It's been very nice to use :)

one option I could explore is creating a command for the extension to enable / disable, which then it might be possible to attach a key-bind to trigger that toggle command. Would that be acceptable in your case?

This would be exactly what I'd like myself—I appreciate being able to see the full contents by default, but would love to be able to hide/show them on command to reveal the TS type info that shows below, without needing to scroll down to it.

(I believe you actually already had this command implemented a couple months ago—toggleHover—and I regularly used it with a keybinding, along with VSCodeVim's gh keybinding for triggering a hover on the cursor)

If possible, would you mind sharing the type that is displayed that’s too large, and what the resulting type preview from the extension is? I am hopeful my current changes for the next release address it address it already.

Here's one example (fairly tame—some types can be much larger than this):

Screen Shot 2024-09-06 at 6 54 37 PM

(move cursor into window, scroll down)

Screen Shot 2024-09-06 at 6 54 42 PM