aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-02-24 22:55:48 +0000
committerVeetaha <[email protected]>2020-02-24 22:55:48 +0000
commit8c6581dcc3db0e79a075d22ab930cb58a31dfe3c (patch)
treef57c36382db2653a9b210d16306b9e7aaf52b80a /editors
parent56d1ff65324d59623e8483c7cbf03672611cbcdf (diff)
vscode: migrate on_enter to rust-analyzer-api.ts
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/commands/on_enter.ts21
1 files changed, 7 insertions, 14 deletions
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 @@
1import * as vscode from 'vscode'; 1import * as vscode from 'vscode';
2import * as lc from 'vscode-languageclient'; 2import * as ra from '../rust-analyzer-api';
3 3
4import { applySourceChange, SourceChange } from '../source_change'; 4import { applySourceChange } from '../source_change';
5import { Cmd, Ctx } from '../ctx'; 5import { Cmd, Ctx } from '../ctx';
6 6
7async function handleKeypress(ctx: Ctx) { 7async function handleKeypress(ctx: Ctx) {
@@ -10,22 +10,15 @@ async function handleKeypress(ctx: Ctx) {
10 10
11 if (!editor || !client) return false; 11 if (!editor || !client) return false;
12 12
13 const request: lc.TextDocumentPositionParams = { 13 const change = await client.sendRequest(ra.onEnter, {
14 textDocument: { uri: editor.document.uri.toString() }, 14 textDocument: { uri: editor.document.uri.toString() },
15 position: client.code2ProtocolConverter.asPosition( 15 position: client.code2ProtocolConverter.asPosition(
16 editor.selection.active, 16 editor.selection.active,
17 ), 17 ),
18 }; 18 }).catch(_error => {
19 const change = await client.sendRequest<undefined | SourceChange>( 19 // client.logFailedRequest(OnEnterRequest.type, error);
20 'rust-analyzer/onEnter', 20 return null;
21 request, 21 });
22 ).catch(
23 (_error: any) => {
24 // FIXME: switch to the more modern (?) typed request infrastructure
25 // client.logFailedRequest(OnEnterRequest.type, error);
26 return Promise.resolve(null);
27 }
28 );
29 if (!change) return false; 22 if (!change) return false;
30 23
31 await applySourceChange(ctx, change); 24 await applySourceChange(ctx, change);