From 8c6581dcc3db0e79a075d22ab930cb58a31dfe3c Mon Sep 17 00:00:00 2001 From: Veetaha Date: Tue, 25 Feb 2020 00:55:48 +0200 Subject: vscode: migrate on_enter to rust-analyzer-api.ts --- editors/code/src/commands/on_enter.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'editors/code/src') diff --git a/editors/code/src/commands/on_enter.ts b/editors/code/src/commands/on_enter.ts index 27ae8ec23..285849db7 100644 --- a/editors/code/src/commands/on_enter.ts +++ b/editors/code/src/commands/on_enter.ts @@ -1,7 +1,7 @@ import * as vscode from 'vscode'; -import * as lc from 'vscode-languageclient'; +import * as ra from '../rust-analyzer-api'; -import { applySourceChange, SourceChange } from '../source_change'; +import { applySourceChange } from '../source_change'; import { Cmd, Ctx } from '../ctx'; async function handleKeypress(ctx: Ctx) { @@ -10,22 +10,15 @@ async function handleKeypress(ctx: Ctx) { if (!editor || !client) return false; - const request: lc.TextDocumentPositionParams = { + const change = await client.sendRequest(ra.onEnter, { textDocument: { uri: editor.document.uri.toString() }, position: client.code2ProtocolConverter.asPosition( editor.selection.active, ), - }; - const change = await client.sendRequest( - 'rust-analyzer/onEnter', - request, - ).catch( - (_error: any) => { - // FIXME: switch to the more modern (?) typed request infrastructure - // client.logFailedRequest(OnEnterRequest.type, error); - return Promise.resolve(null); - } - ); + }).catch(_error => { + // client.logFailedRequest(OnEnterRequest.type, error); + return null; + }); if (!change) return false; await applySourceChange(ctx, change); -- cgit v1.2.3