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

Support Advanced Hovers #3026

Open
JustinGrote opened this issue Oct 23, 2020 · 8 comments
Open

Support Advanced Hovers #3026

JustinGrote opened this issue Oct 23, 2020 · 8 comments
Labels
Area-IntelliSense Issue-Enhancement A feature request (enhancement).

Comments

@JustinGrote
Copy link
Collaborator

JustinGrote commented Oct 23, 2020

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
image

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.

@ghost ghost added the Needs: Triage Maintainer attention needed! label Oct 23, 2020
@SydneyhSmith SydneyhSmith added Area-IntelliSense Issue-Enhancement A feature request (enhancement). and removed Needs: Triage Maintainer attention needed! labels Oct 27, 2020
@MartinGC94
Copy link
Contributor

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.

@JustinGrote
Copy link
Collaborator Author

JustinGrote commented Jan 22, 2024

@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 :)

@MartinGC94
Copy link
Contributor

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.

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 :)

Thanks, it's been a great way for me to sharpen my C# skills and I of course also love the UX improvements myself.

@JustinGrote
Copy link
Collaborator Author

@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.

@JustinGrote
Copy link
Collaborator Author

JustinGrote commented Jan 25, 2024

@MartinGC94 I have a basic prototype wired up here:
PowerShell/PowerShellEditorServices#2133

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.

@JustinGrote
Copy link
Collaborator Author

JustinGrote commented Jan 25, 2024

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 CompletionResult for pretty much every token (we could potentially do some smart scope deduplication) that is on the screen and refresh all of it either when the document changes or the view changes (if we limit completions to just what is on screen)

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.

@andyleejordan
Copy link
Member

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.

@JustinGrote
Copy link
Collaborator Author

@andyleejordan you probably sent it to me and it fell off my to-look list :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IntelliSense Issue-Enhancement A feature request (enhancement).
Projects
None yet
Development

No branches or pull requests

4 participants