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

Hover hint improvement in function parameter context #715

Open
tanzanite777 opened this issue Oct 30, 2024 · 3 comments
Open

Hover hint improvement in function parameter context #715

tanzanite777 opened this issue Oct 30, 2024 · 3 comments
Labels
feature New feature or request

Comments

@tanzanite777
Copy link

tanzanite777 commented Oct 30, 2024

Type: Feature Request

Inlay hints ( which for most of it i begrudgingly had to turn off :( - messes way too much with editing and layout/readability ) reminded me of a feature i would really like (and i cannot be alone in this) - and it might even be trivial to implement ... function parameter context on hover.

An example to explain:

/** @param string $par doc */
function foo(string $par) : string { return "x$par"; }
function bar() : string { return 'y'; }

$s = 'x';
echo foo(bar() . $s . 'x');

Hovering any of "bar", "$s" or "'x'" on the last line of code when a modifier key ("alt" seems to be free as a possible default and makes sense) is held would show an alternate context hover hint about the first parameter of function "foo". Basically a carbon copy of what one would see when hovering "$par" in the function "foo" definition:

(parameter) string $par
doc

This "alt" context hint behavior could even be generalized - however i cannot think of much atm:

  • Function parameter context -> parameter hint as explained - VERY useful.
  • Function body context -> function hint - somewhat useful (to see relevant documentation while editing/reading inside longish function body).
  • Class body context -> class hint (ie. doc-block as the rest is covered by declaration line sticking on top) - fairly useless.

Extension version: 1.52.16273
VS Code version: Code 1.94.2 (384ff7382de624fb94dbaf6da11977bba1ecd427, 2024-10-09T16:08:44.566Z)
OS version: Windows_NT x64 10.0.19045
Modes:

@jakubmisek jakubmisek added the feature New feature or request label Oct 31, 2024
@jakubmisek
Copy link
Member

jakubmisek commented Nov 3, 2024

Thank you for the suggestion, good idea!

We can (should) respect the "show definition hover" aka "preview of the declaration" feature (hover while holding modifier key, i.e. Ctrl/Cmd+Hover as described at https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)

We'll try to implement this one.

@tanzanite777
Copy link
Author

Not sure i got the ctrl+hover reference - was the idea that alt+hover would also make the whole "bar() . $s . 'x'" parameter clickable and it would land on the "foo" function - ie. similar to ctrl+hover on identifiers? If so then yeah - might sometimes be convenient indeed.

@jakubmisek
Copy link
Member

I agree. Sadly VSCode API does not let us handle Alt or Ctrl explicitly. That may be a bit tricky to extend the editor with another clickable element with a custom mouse hover.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants