feat(lsp): double-click-to-insert text edits on type inlay hints#4080
feat(lsp): double-click-to-insert text edits on type inlay hints#4080codeshaunted wants to merge 2 commits into
Conversation
Type hints on let bindings now carry LSP textEdits inserting the label at the hint position, so VS Code's double-click-to-apply turns a ': int' hint into a real annotation (rust-analyzer style). Edits are attached only when the rendered type is valid, resolvable surface syntax, via a new ty_is_insertable walk on Ty. Verified against the compiler: enum variants, function types with throws, never, unknown, type, int/bigint literal types, and interface names are insertable; Future<...> (unresolvable), _[] / map<_, _> (never-evolved empty literals), float literal types (parser rejects), synthetic callback effect params, associated-type projections, and opaque runtime leafs are not. Parameter-name hints get no edits (nothing to insert).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughType and parameter inlay annotations now expose an ChangesInlay hint editability
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TypeHintGenerator
participant InlineAnnotation
participant InlayHintHandler
participant LSPClient
TypeHintGenerator->>InlineAnnotation: create annotation with insertable flag
InlineAnnotation->>InlayHintHandler: provide label and insertability
InlayHintHandler->>LSPClient: return conditional text edit
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Binary size checks failed❌ 4 violations · ✅ 3 passed
Details & how to fixViolations:
Add/update baselines:
[artifacts.baml-cli]
file_bytes = 19528560
stripped_bytes = 19528608
gzip_bytes = 9324616
[artifacts.bridge_wasm]
file_bytes = 16161152
gzip_bytes = 4403113
[artifacts.baml-cli]
file_bytes = 21048832
stripped_bytes = 21048832
gzip_bytes = 9535103
[artifacts.baml-cli]
file_bytes = 25245456
stripped_bytes = 25245448
gzip_bytes = 10721454Generated by |
Type inlay hints on
letbindings now carry LSPtextEditsthat insert the label at the hint position, so double-clicking a hint in VS Code turns: intinto a real annotation (rust-analyzer style). Parameter-name hints get no edits since there is nothing to insert.Edits are attached only when the rendered type is valid, resolvable surface syntax, decided by a new
ty_is_insertablewalk onTyinbaml_lsp2_actions::annotations. The classification was verified againstbaml-cli checkrather than guessed:Insertable: primitives, classes, enums, enum variants (
Color.R), unions, maps, lists, function types withthrowsclauses,never,unknown,type, int/bigint/negative literal types, interface names, in-scope generic params, evolved empty literals (render as plainint[]).Not insertable:
Future<...>(unresolvable name in type position),_[]/map<_, _>(never-evolved empty literals, not parseable), float literal types (parser rejects), syntheticcallbackeffect params, associated-type projections,void, and the opaque runtime leafs ($rust_type,baml.llm.Resource,baml.llm.PromptAst).The LSP handler builds the edit as a zero-width insert at the hint offset with the label text;
resolve_providerstaysfalsesince edits are attached eagerly.Summary by CodeRabbit
New Features
Bug Fixes