Skip to content

Implement hint dynamic unfolding #11702

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

Closed
SomeoneToIgnore opened this issue Mar 14, 2022 · 8 comments
Closed

Implement hint dynamic unfolding #11702

SomeoneToIgnore opened this issue Mar 14, 2022 · 8 comments
Labels
A-inlay-hints inlay/inline hints C-feature Category: feature request S-actionable Someone could pick this issue up and work on it right now

Comments

@SomeoneToIgnore
Copy link
Contributor

SomeoneToIgnore commented Mar 14, 2022

Depending on the user settings, rust-analyzer server can fold too long hints, i.e. HashMap<String, Vec<...>>.

Now, when the VSCode client hints consist of ranges and support dynamic actions, we can make those folded hints dynamic and unfold them on click, similarly how Intellij does this now.

@SomeoneToIgnore SomeoneToIgnore added S-actionable Someone could pick this issue up and work on it right now C-feature Category: feature request A-inlay-hints inlay/inline hints labels Mar 14, 2022
@roife
Copy link
Member

roife commented Apr 17, 2025

I find this feature very interesting! I would like to take the time to explore its implementation.

Currently, ctrl + click the inlay hint label triggers the corresponding commands. My suggestion is that when the type is too long, it should display as Option<…>. ctrl + click the would then expand it to Option<i32> ↩, and ctrl + click the would collapse it back.

@roife roife self-assigned this Apr 17, 2025
@roife
Copy link
Member

roife commented Apr 17, 2025

The main challenge is that the server cannot control when the client refreshes the inlay hints. As a result, we may need to add a state to server to track the expanded status of the hints, which could complicate the server.

@Veykril
Copy link
Member

Veykril commented Apr 17, 2025

This sounds more like logic that the client should contain, not the server. So I don't think this is workable from our side

@roife
Copy link
Member

roife commented Apr 17, 2025

It's indeed more suitable for the client to implement. Currently, VS Code truncates hints that exceed a certain length. A better solution would be to selectively collapse deeper hints based on their labels. However, the client needs to understand the structure of these labels to do this...

@Veykril
Copy link
Member

Veykril commented Apr 17, 2025

The client has that information, the lsp encodes inlay hint parts already. To me this really sounds more like a feature request for editors (that is VSCode, Zed, etc)

@roife roife removed their assignment Apr 17, 2025
@SomeoneToIgnore
Copy link
Contributor Author

I actually agree now with the "it should be done in the editor" sentiment in the current days, hence closing.

@roife
Copy link
Member

roife commented Apr 17, 2025

How about adding a tooltip to ... that displays the collapsed part or the entire type? Currently, the only way to view hidden parts is to select the expression and hover over it.

@Veykril
Copy link
Member

Veykril commented Apr 17, 2025

That we can do on the server yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inlay-hints inlay/inline hints C-feature Category: feature request S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

3 participants