mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 05:15:04 +00:00
vscode: migrate matching_brace to rust-analyzer-api.ts
This commit is contained in:
parent
38d7945ec7
commit
56d1ff6532
1 changed files with 3 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as lc from 'vscode-languageclient';
|
import * as ra from '../rust-analyzer-api';
|
||||||
|
|
||||||
import { Ctx, Cmd } from '../ctx';
|
import { Ctx, Cmd } from '../ctx';
|
||||||
|
|
||||||
|
@ -9,16 +9,12 @@ export function matchingBrace(ctx: Ctx): Cmd {
|
||||||
const client = ctx.client;
|
const client = ctx.client;
|
||||||
if (!editor || !client) return;
|
if (!editor || !client) return;
|
||||||
|
|
||||||
const request: FindMatchingBraceParams = {
|
const response = await client.sendRequest(ra.findMatchingBrace, {
|
||||||
textDocument: { uri: editor.document.uri.toString() },
|
textDocument: { uri: editor.document.uri.toString() },
|
||||||
offsets: editor.selections.map(s =>
|
offsets: editor.selections.map(s =>
|
||||||
client.code2ProtocolConverter.asPosition(s.active),
|
client.code2ProtocolConverter.asPosition(s.active),
|
||||||
),
|
),
|
||||||
};
|
});
|
||||||
const response = await client.sendRequest<lc.Position[]>(
|
|
||||||
'rust-analyzer/findMatchingBrace',
|
|
||||||
request,
|
|
||||||
);
|
|
||||||
editor.selections = editor.selections.map((sel, idx) => {
|
editor.selections = editor.selections.map((sel, idx) => {
|
||||||
const active = client.protocol2CodeConverter.asPosition(
|
const active = client.protocol2CodeConverter.asPosition(
|
||||||
response[idx],
|
response[idx],
|
||||||
|
@ -29,8 +25,3 @@ export function matchingBrace(ctx: Ctx): Cmd {
|
||||||
editor.revealRange(editor.selection);
|
editor.revealRange(editor.selection);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FindMatchingBraceParams {
|
|
||||||
textDocument: lc.TextDocumentIdentifier;
|
|
||||||
offsets: lc.Position[];
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue