diff options
author | Aleksey Kladov <[email protected]> | 2019-04-21 10:13:48 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-04-21 10:13:48 +0100 |
commit | fa12ed2b8f3466af88644e59127cd169549f8899 (patch) | |
tree | 8837e4192d6121115a5a9b94044d33bd683184b2 /editors/code/src | |
parent | 31b7697cf6f4ebb4ebc35b055e6b4ad9a28e28e9 (diff) |
switch to official extend selection API
Diffstat (limited to 'editors/code/src')
-rw-r--r-- | editors/code/src/commands/extend_selection.ts | 34 | ||||
-rw-r--r-- | editors/code/src/commands/index.ts | 2 | ||||
-rw-r--r-- | editors/code/src/extension.ts | 4 | ||||
-rw-r--r-- | editors/code/src/server.ts | 1 |
4 files changed, 1 insertions, 40 deletions
diff --git a/editors/code/src/commands/extend_selection.ts b/editors/code/src/commands/extend_selection.ts deleted file mode 100644 index 6f4187d15..000000000 --- a/editors/code/src/commands/extend_selection.ts +++ /dev/null | |||
@@ -1,34 +0,0 @@ | |||
1 | import * as vscode from 'vscode'; | ||
2 | |||
3 | import { Range, TextDocumentIdentifier } 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 | const editor = vscode.window.activeTextEditor; | ||
17 | if (editor == null || editor.document.languageId !== 'rust') { | ||
18 | return; | ||
19 | } | ||
20 | const request: ExtendSelectionParams = { | ||
21 | selections: editor.selections.map(s => | ||
22 | Server.client.code2ProtocolConverter.asRange(s) | ||
23 | ), | ||
24 | textDocument: { uri: editor.document.uri.toString() } | ||
25 | }; | ||
26 | const response = await Server.client.sendRequest<ExtendSelectionResult>( | ||
27 | 'rust-analyzer/extendSelection', | ||
28 | request | ||
29 | ); | ||
30 | editor.selections = response.selections.map((range: Range) => { | ||
31 | const r = Server.client.protocol2CodeConverter.asRange(range); | ||
32 | return new vscode.Selection(r.start, r.end); | ||
33 | }); | ||
34 | } | ||
diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index f36c4b040..194658497 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import * as analyzerStatus from './analyzer_status'; | 1 | import * as analyzerStatus from './analyzer_status'; |
2 | import * as applySourceChange from './apply_source_change'; | 2 | import * as applySourceChange from './apply_source_change'; |
3 | import * as extendSelection from './extend_selection'; | ||
4 | import * as joinLines from './join_lines'; | 3 | import * as joinLines from './join_lines'; |
5 | import * as matchingBrace from './matching_brace'; | 4 | import * as matchingBrace from './matching_brace'; |
6 | import * as onEnter from './on_enter'; | 5 | import * as onEnter from './on_enter'; |
@@ -11,7 +10,6 @@ import * as syntaxTree from './syntaxTree'; | |||
11 | export { | 10 | export { |
12 | analyzerStatus, | 11 | analyzerStatus, |
13 | applySourceChange, | 12 | applySourceChange, |
14 | extendSelection, | ||
15 | joinLines, | 13 | joinLines, |
16 | matchingBrace, | 14 | matchingBrace, |
17 | parentModule, | 15 | parentModule, |
diff --git a/editors/code/src/extension.ts b/editors/code/src/extension.ts index 48dd2a614..c8c3004a7 100644 --- a/editors/code/src/extension.ts +++ b/editors/code/src/extension.ts | |||
@@ -58,10 +58,6 @@ export function activate(context: vscode.ExtensionContext) { | |||
58 | Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null) | 58 | Server.client.sendRequest<null>('rust-analyzer/collectGarbage', null) |
59 | ); | 59 | ); |
60 | registerCommand( | 60 | registerCommand( |
61 | 'rust-analyzer.extendSelection', | ||
62 | commands.extendSelection.handle | ||
63 | ); | ||
64 | registerCommand( | ||
65 | 'rust-analyzer.matchingBrace', | 61 | 'rust-analyzer.matchingBrace', |
66 | commands.matchingBrace.handle | 62 | commands.matchingBrace.handle |
67 | ); | 63 | ); |
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts index 5e9a19340..81c2b3fff 100644 --- a/editors/code/src/server.ts +++ b/editors/code/src/server.ts | |||
@@ -74,6 +74,7 @@ export class Server { | |||
74 | } | 74 | } |
75 | } | 75 | } |
76 | }; | 76 | }; |
77 | Server.client.registerProposedFeatures(); | ||
77 | Server.client.onReady().then(() => { | 78 | Server.client.onReady().then(() => { |
78 | for (const [type, handler] of notificationHandlers) { | 79 | for (const [type, handler] of notificationHandlers) { |
79 | Server.client.onNotification(type, handler); | 80 | Server.client.onNotification(type, handler); |