This commit is contained in:
Laurențiu Nicola 2022-02-10 12:16:02 +02:00
parent 5a49dbd2e0
commit 0b69717ab6
3 changed files with 5 additions and 5 deletions

View File

@ -247,7 +247,6 @@ pub struct InlayHintsParams {
pub struct InlayHintKind(u8);
impl InlayHintKind {
pub const OTHER: InlayHintKind = InlayHintKind(0);
pub const TYPE: InlayHintKind = InlayHintKind(1);
pub const PARAMETER: InlayHintKind = InlayHintKind(2);
}

View File

@ -413,11 +413,11 @@ pub(crate) fn signature_help(
pub(crate) fn inlay_hint(line_index: &LineIndex, inlay_hint: InlayHint) -> lsp_ext::InlayHint {
lsp_ext::InlayHint {
label: inlay_hint.label.to_string(),
position: position(line_index, inlay_hint.range.start()),
position: position(line_index, inlay_hint.range.end()),
kind: Some(match inlay_hint.kind {
InlayKind::ParameterHint => lsp_ext::InlayHintKind::PARAMETER,
InlayKind::TypeHint => lsp_ext::InlayHintKind::TYPE,
InlayKind::ChainingHint => lsp_ext::InlayHintKind::OTHER,
InlayKind::ChainingHint => lsp_ext::InlayHintKind::TYPE,
}),
tooltip: Some("test description".to_string()),
padding_left: Some(true),

View File

@ -22,13 +22,14 @@ export function activateInlayHints(ctx: Ctx) {
this.hintsProvider = vscode.languages.registerInlayHintsProvider({ scheme: 'file', language: 'rust' }, new class implements vscode.InlayHintsProvider {
onDidChangeInlayHints = event;
async provideInlayHints(document: vscode.TextDocument, range: vscode.Range, token: vscode.CancellationToken): Promise<vscode.InlayHint[]> {
console.log(document.uri.toString());
const request = { textDocument: { uri: document.uri.toString() }, range: { start: range.start, end: range.end } };
const hints = await sendRequestWithRetry(ctx.client, ra.inlayHints, request, token).catch(_ => null);
console.log(hints);
if (hints == null) {
return [];
} else {
for (let hint of hints) {
hint.position = new vscode.Position(hint.position.line, hint.position.character);
}
return hints;
}
}