From 7c7f8d1a174dc895c0feb5f9c46ca4c4992cc2bc Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 27 Nov 2025 13:29:11 +0100 Subject: [PATCH] [ty] Make inlay hint clickable in playground (#21656) --- crates/ty_wasm/src/lib.rs | 16 ++++++++++++++++ playground/ty/src/Editor/Editor.tsx | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/crates/ty_wasm/src/lib.rs b/crates/ty_wasm/src/lib.rs index 8e05b5e15f..a1ecb73062 100644 --- a/crates/ty_wasm/src/lib.rs +++ b/crates/ty_wasm/src/lib.rs @@ -493,6 +493,19 @@ impl Workspace { self.position_encoding, ), kind: hint.kind.into(), + text_edits: hint + .text_edits + .into_iter() + .map(|edit| TextEdit { + range: Range::from_text_range( + edit.range, + &index, + &source, + self.position_encoding, + ), + new_text: edit.new_text, + }) + .collect(), }) .collect()) } @@ -1110,6 +1123,9 @@ pub struct InlayHint { pub position: Position, pub kind: InlayHintKind, + + #[wasm_bindgen(getter_with_clone)] + pub text_edits: Vec, } #[wasm_bindgen] diff --git a/playground/ty/src/Editor/Editor.tsx b/playground/ty/src/Editor/Editor.tsx index 5fd899b19b..9b694bb829 100644 --- a/playground/ty/src/Editor/Editor.tsx +++ b/playground/ty/src/Editor/Editor.tsx @@ -463,6 +463,10 @@ class PlaygroundServer column: hint.position.column, }, kind: mapInlayHintKind(hint.kind), + textEdits: hint.text_edits.map((edit: TextEdit) => ({ + range: tyRangeToMonacoRange(edit.range), + text: edit.new_text, + })), })), }; }