Repository navigation
Allow accepting inlay hints via click and provide code action to apply unambiguous hints #51582
Replies: 4 comments
|
The But I agree, there needs to be an action that converts the selected variable's hint into an explicit hint with one click/one command. That would make it easier to apply types to old codebases. Especially when using ty. I wrote about that here in my comparison between Pyrefly and Ty, the two next-generation Python LSPs. Pyrefly has a tool that can auto-add type hints to any given file. But ty can't do that and relies on your IDE being able to convert auto-hints into explicit hints. |
|
Closed via #64789 , should be available in Zed Preview next week, Zed Stable the week after that. |
|
I dont use that i think I used it once or twice is vscode and zed but to my knowledge it was only with copilot and I think because my keybindings are set to vscode I can just press tab and it accepts it I'll check it out though |
|
Accepting individual inlay hints has shipped in Zed Stable v1.25.2! |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Allow accepting inlay hints by clicking on them, and optionally provide a code action to apply all unambiguous inlay hints in the current file.
Problem
Inlay hints are useful for understanding code, but they are currently only informational in Zed. There is no way to directly convert them into actual code. For users who prefer explicitly typed code (for example in Python), this means manually rewriting information that is already visible in the editor.
Proposed solution
1. Allow accepting inlay hints by clicking on them
Allow users to click directly on an inlay hint to insert its content into the buffer.
Example workflow with VS code pylance:
This would provide a very fast way to convert hints into explicit code.
Motivation
This feature already exists in the Pylance language server for VS Code, where inlay hints can be accepted interactively.
However, in that case the feature is implemented inside the language server rather than the editor itself.
If Zed implemented this behavior at the editor level, it could work with any language server that provides inlay hints, which would make the feature much more broadly useful.
I mainly work with Python, so I cannot confidently say how applicable this would be to other languages, but if the interaction is language-agnostic it could become an even more powerful capability.
2. Optional code action: apply all unambiguous hints
Once inserting hints individually is possible, it would likely be straightforward to add a code action such as:
This could automatically insert hints where the transformation is deterministic and complete, while ignoring ambiguous cases (no
...orAnyin the suggestion), significantly speeding up workflows where developers want to convert implicit code into fully explicit, typed code.Why this would help
All reactions