aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src
diff options
context:
space:
mode:
authorVeetaha <[email protected]>2020-02-24 22:55:13 +0000
committerVeetaha <[email protected]>2020-02-24 22:55:13 +0000
commit56d1ff65324d59623e8483c7cbf03672611cbcdf (patch)
treea25ccd11fb9f7eecba583b1694e917f50fa0de89 /editors/code/src
parent38d7945ec7d3522e09a105a92156d1aaf8651f46 (diff)
vscode: migrate matching_brace to rust-analyzer-api.ts
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands/matching_brace.ts15
1 files changed, 3 insertions, 12 deletions
diff --git a/editors/code/src/commands/matching_brace.ts b/editors/code/src/commands/matching_brace.ts
index 7c58bb7e7..a60776e2d 100644
--- a/editors/code/src/commands/matching_brace.ts
+++ b/editors/code/src/commands/matching_brace.ts
@@ -1,5 +1,5 @@
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 { Ctx, Cmd } from '../ctx'; 4import { Ctx, Cmd } from '../ctx';
5 5
@@ -9,16 +9,12 @@ export function matchingBrace(ctx: Ctx): Cmd {
9 const client = ctx.client; 9 const client = ctx.client;
10 if (!editor || !client) return; 10 if (!editor || !client) return;
11 11
12 const request: FindMatchingBraceParams = { 12 const response = await client.sendRequest(ra.findMatchingBrace, {
13 textDocument: { uri: editor.document.uri.toString() }, 13 textDocument: { uri: editor.document.uri.toString() },
14 offsets: editor.selections.map(s => 14 offsets: editor.selections.map(s =>
15 client.code2ProtocolConverter.asPosition(s.active), 15 client.code2ProtocolConverter.asPosition(s.active),
16 ), 16 ),
17 }; 17 });
18 const response = await client.sendRequest<lc.Position[]>(
19 'rust-analyzer/findMatchingBrace',
20 request,
21 );
22 editor.selections = editor.selections.map((sel, idx) => { 18 editor.selections = editor.selections.map((sel, idx) => {
23 const active = client.protocol2CodeConverter.asPosition( 19 const active = client.protocol2CodeConverter.asPosition(
24 response[idx], 20 response[idx],
@@ -29,8 +25,3 @@ export function matchingBrace(ctx: Ctx): Cmd {
29 editor.revealRange(editor.selection); 25 editor.revealRange(editor.selection);
30 }; 26 };
31} 27}
32
33interface FindMatchingBraceParams {
34 textDocument: lc.TextDocumentIdentifier;
35 offsets: lc.Position[];
36}