-
Notifications
You must be signed in to change notification settings - Fork 494
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
Support Advanced Hovers #3026
Comments
It would also be nice if hovering over a variable/property would show the type like Visual Studio does. If the variable/property doesn't currently have a value the internal PowerShell type inference code could be used. |
@MartinGC94 that feature would be better suited as an inlay hint but I agree, we could definitely offer a high confidence and best effort inference here, it's one of my to-dos after inline breakpointing. https://www.youtube.com/watch?v=uvrIFZYW7eg Also I'm going to use this opportunity to MASSIVELY thank you for all of your completion and autocomplete fixups you've done over the past year or two, they make my quality of life so much better :) |
I hadn't heard about inlay hints before. They seem neat, though I'd still prefer the hover tooltips but maybe I'll change my mind if I try to use those hints.
Thanks, it's been a great way for me to sharpen my C# skills and I of course also love the UX improvements myself. |
@MartinGC94 they are awesome and fully implemented in Typescript/F#/C# extensions. Try opening a file and hitting ctrl-alt. You can also configure them to be persistently visible for various types. |
@MartinGC94 I have a basic prototype wired up here: Can you point me to docs or the API that is the best way to find the inferred types of variables and parameters in PowerShell? Ideally one that does a single pass of a whole document/script as efficiently as possible rather than a ton of individual AST visits. EDIT: I realized I can sort of look at how the current completion handler works for properties/etc. to determine the symbol type and steal that for now for a proof of concept. |
OK, after some experimentation and discussion with @SeeminglyScience, doing inlay hints is probably not feasible as of PS7.4, as the current implementation would basically have to get a Until PowerShell has a performant API that can provide a visitor for gathering this kind of info, it's doable but it would be slow AF and not super useful. Enhancing the hovers however is definitely doable and something I'll explore some more. I may scaffold out the inlay hover further as experimental for both variables and parameters and that way the completion engine can just get swapped out when we have a better/faster way. |
I would love to see the existing hovers made better. Not sure if you saw PowerShell/PowerShellEditorServices#2127. There's a lot we could do. |
@andyleejordan you probably sent it to me and it fell off my to-look list :) |
I was investigating this a but further today. While we could theoretically offer this today, unfortunately to do inline hints "simply", requires running completion for every variable/parameter symbol in the document, which even if we defer in the pipeline, will result in a lot of compute and while fine for relatively small scripts, would end up being very slow for large scripts. We would be able to optimize by potentially only doing deltas after that, but it's still really heavyweight by virtue of that it would have to run within the runspace. The alternative is utilize several of the additions from the rename provider to do static AST analysis. For example:
We effectively expand on the rename I'll experiment with this more. |
Summary of the new feature
The existing powershell hover for commands/functions is very basic and only provides the synopsis. VScode now supports colorized advanced hovers, and Omnisharp C# extension already implements this as a reference.
https://code.visualstudio.com/api/language-extensions/programmatic-language-features#show-hovers
Powershell should support the same for functions and methods, displaying colorized syntax info about the function, and ideally not just the synopsis but parameter descriptions. The verbosity could be controlled via a setting.
Proposed technical implementation details (optional)
This should be done after the parser rewrite. It should probably be tagged a good-first-issue as well, I'd be willing to give it a shot once the parser rewrite is done to avoid a moving target.
This could also be a good candidate as a separate extension for the extension API that @TylerLeonhardt was working on, though it may be difficult to make sure the two don't clobber each other.
The text was updated successfully, but these errors were encountered: