Skip to content

Commit

Permalink
apply the type parameter hitns as a text edit (#1692)
Browse files Browse the repository at this point in the history
  • Loading branch information
baronfel authored Apr 20, 2022
1 parent ed65d62 commit 0200d58
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Components/InlayHints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ let actuallyEnabled () =
enabled ()
&& (allowTypeAnnotations () || allowParameterNames ())

let inline createEdit (h: LanguageService.Types.InlayHint): TextEdit =
let e = createEmpty<TextEdit>
e.range <- vscode.Range.Create(h.pos, h.pos)
e.newText <- h.text
e

let toInlayHint (fsacHint: LanguageService.Types.InlayHint) : InlayHint =
let h = createEmpty<InlayHint>
h.position <- vscode.Position.Create(fsacHint.pos.line, fsacHint.pos.character)
Expand All @@ -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 () =
Expand Down

0 comments on commit 0200d58

Please sign in to comment.