diff options
Diffstat (limited to 'editors/code/src/commands/extend_selection.ts')
-rw-r--r-- | editors/code/src/commands/extend_selection.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/editors/code/src/commands/extend_selection.ts b/editors/code/src/commands/extend_selection.ts new file mode 100644 index 000000000..b90828ba9 --- /dev/null +++ b/editors/code/src/commands/extend_selection.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | import { TextDocumentIdentifier, Range } from "vscode-languageclient"; | ||
4 | import { Server } from '../server'; | ||
5 | |||
6 | interface ExtendSelectionParams { | ||
7 | textDocument: TextDocumentIdentifier; | ||
8 | selections: Range[]; | ||
9 | } | ||
10 | |||
11 | interface ExtendSelectionResult { | ||
12 | selections: Range[]; | ||
13 | } | ||
14 | |||
15 | export async function handle() { | ||
16 | let editor = vscode.window.activeTextEditor | ||
17 | if (editor == null || editor.document.languageId != "rust") return | ||
18 | let request: ExtendSelectionParams = { | ||
19 | textDocument: { uri: editor.document.uri.toString() }, | ||
20 | selections: editor.selections.map((s) => { | ||
21 | return Server.client.code2ProtocolConverter.asRange(s) | ||
22 | }) | ||
23 | } | ||
24 | let response = await Server.client.sendRequest<ExtendSelectionResult>("m/extendSelection", request) | ||
25 | editor.selections = response.selections.map((range: Range) => { | ||
26 | let r = Server.client.protocol2CodeConverter.asRange(range) | ||
27 | return new vscode.Selection(r.start, r.end) | ||
28 | }) | ||
29 | } | ||