From fa12ed2b8f3466af88644e59127cd169549f8899 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 21 Apr 2019 12:13:48 +0300 Subject: switch to official extend selection API --- editors/code/package.json | 5 ---- editors/code/src/commands/extend_selection.ts | 34 --------------------------- editors/code/src/commands/index.ts | 2 -- editors/code/src/extension.ts | 4 ---- editors/code/src/server.ts | 1 + 5 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 editors/code/src/commands/extend_selection.ts (limited to 'editors') diff --git a/editors/code/package.json b/editors/code/package.json index 8f195c996..015b912b3 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -80,11 +80,6 @@ "title": "Show Syntax Tree", "category": "Rust Analyzer" }, - { - "command": "rust-analyzer.extendSelection", - "title": "Extend selection", - "category": "Rust Analyzer" - }, { "command": "rust-analyzer.matchingBrace", "title": "Find matching brace", 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 @@ -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( - '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); - }); -} 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 @@ import * as analyzerStatus from './analyzer_status'; import * as applySourceChange from './apply_source_change'; -import * as extendSelection from './extend_selection'; import * as joinLines from './join_lines'; import * as matchingBrace from './matching_brace'; import * as onEnter from './on_enter'; @@ -11,7 +10,6 @@ import * as syntaxTree from './syntaxTree'; export { analyzerStatus, applySourceChange, - extendSelection, joinLines, matchingBrace, 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 @@ -57,10 +57,6 @@ export function activate(context: vscode.ExtensionContext) { registerCommand('rust-analyzer.collectGarbage', () => Server.client.sendRequest('rust-analyzer/collectGarbage', null) ); - registerCommand( - 'rust-analyzer.extendSelection', - commands.extendSelection.handle - ); registerCommand( 'rust-analyzer.matchingBrace', commands.matchingBrace.handle 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 { } } }; + Server.client.registerProposedFeatures(); Server.client.onReady().then(() => { for (const [type, handler] of notificationHandlers) { Server.client.onNotification(type, handler); -- cgit v1.2.3