blob: 6f4187d15c3868e9a8a516e234a756eceddfb3e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
import * as vscode from 'vscode';
import { Range, TextDocumentIdentifier } from 'vscode-languageclient';
import { Server } from '../server';
interface ExtendSelectionParams {
textDocument: TextDocumentIdentifier;
selections: Range[];
}
interface ExtendSelectionResult {
selections: Range[];
}
export async function handle() {
const editor = vscode.window.activeTextEditor;
if (editor == null || editor.document.languageId !== 'rust') {
return;
}
const request: ExtendSelectionParams = {
selections: editor.selections.map(s =>
Server.client.code2ProtocolConverter.asRange(s)
),
textDocument: { uri: editor.document.uri.toString() }
};
const response = await Server.client.sendRequest<ExtendSelectionResult>(
'rust-analyzer/extendSelection',
request
);
editor.selections = response.selections.map((range: Range) => {
const r = Server.client.protocol2CodeConverter.asRange(range);
return new vscode.Selection(r.start, r.end);
});
}
|