From 4eacd3ccc5c59527a5e871b82cb6b039914b5f6d Mon Sep 17 00:00:00 2001 From: Chet Husk Date: Tue, 19 Apr 2022 20:31:04 -0500 Subject: [PATCH] apply the type parameter hitns as a text edit --- src/Components/InlayHints.fs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Components/InlayHints.fs b/src/Components/InlayHints.fs index 618a5b77..737ec700 100644 --- a/src/Components/InlayHints.fs +++ b/src/Components/InlayHints.fs @@ -23,6 +23,12 @@ let actuallyEnabled () = enabled () && (allowTypeAnnotations () || allowParameterNames ()) +let inline createEdit (h: LanguageService.Types.InlayHint): TextEdit = + let e = createEmpty + e.range <- vscode.Range.Create(h.pos, h.pos) + e.newText <- h.text + e + let toInlayHint (fsacHint: LanguageService.Types.InlayHint) : InlayHint = let h = createEmpty h.position <- vscode.Position.Create(fsacHint.pos.line, fsacHint.pos.character) @@ -32,11 +38,13 @@ let toInlayHint (fsacHint: LanguageService.Types.InlayHint) : InlayHint = | "Type" -> h.paddingLeft <- Some true h.kind <- Some InlayHintKind.Type + h.textEdits <- Some (ResizeArray([ createEdit fsacHint ])) | "Parameter" -> h.paddingRight <- Some true h.kind <- Some InlayHintKind.Parameter + // TODO: we don't easily create edits for parameter names - it might help if the insert text + // was provided from FSAC as well (because FSAC knows if parens would be required, etc) | _ -> () - h let inlayProvider () =