mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Refactor vscode extension
This commit is contained in:
parent
e4fdfd1501
commit
69de7e2fd7
14 changed files with 518 additions and 415 deletions
29
editors/code/src/commands/extend_selection.ts
Normal file
29
editors/code/src/commands/extend_selection.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { TextDocumentIdentifier, Range } from "vscode-languageclient";
|
||||
import { Server } from '../server';
|
||||
|
||||
interface ExtendSelectionParams {
|
||||
textDocument: TextDocumentIdentifier;
|
||||
selections: Range[];
|
||||
}
|
||||
|
||||
interface ExtendSelectionResult {
|
||||
selections: Range[];
|
||||
}
|
||||
|
||||
export async function handle() {
|
||||
let editor = vscode.window.activeTextEditor
|
||||
if (editor == null || editor.document.languageId != "rust") return
|
||||
let request: ExtendSelectionParams = {
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
selections: editor.selections.map((s) => {
|
||||
return Server.client.code2ProtocolConverter.asRange(s)
|
||||
})
|
||||
}
|
||||
let response = await Server.client.sendRequest<ExtendSelectionResult>("m/extendSelection", request)
|
||||
editor.selections = response.selections.map((range: Range) => {
|
||||
let r = Server.client.protocol2CodeConverter.asRange(range)
|
||||
return new vscode.Selection(r.start, r.end)
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue