From 83d2527880d86653ce00940c65620319b36afcff Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Dec 2019 15:50:15 +0100 Subject: Move joinLines to the new Ctx --- editors/code/src/commands/index.ts | 2 +- editors/code/src/commands/join_lines.ts | 38 ++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'editors/code/src/commands') diff --git a/editors/code/src/commands/index.ts b/editors/code/src/commands/index.ts index 9d9b9c575..8090c7e5b 100644 --- a/editors/code/src/commands/index.ts +++ b/editors/code/src/commands/index.ts @@ -2,10 +2,10 @@ import { Ctx, Cmd } from '../ctx' import { analyzerStatus } from './analyzer_status'; import { matchingBrace } from './matching_brace'; +import { joinLines } from './join_lines'; import * as applySourceChange from './apply_source_change'; import * as expandMacro from './expand_macro'; import * as inlayHints from './inlay_hints'; -import * as joinLines from './join_lines'; import * as onEnter from './on_enter'; import * as parentModule from './parent_module'; import * as runnables from './runnables'; diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts index 134ddc801..7952fb0c0 100644 --- a/editors/code/src/commands/join_lines.ts +++ b/editors/code/src/commands/join_lines.ts @@ -1,29 +1,29 @@ -import * as vscode from 'vscode'; - import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; -import { Server } from '../server'; +import { Ctx, Cmd } from '../ctx'; import { handle as applySourceChange, SourceChange, } from './apply_source_change'; +export function joinLines(ctx: Ctx): Cmd { + return async () => { + const editor = ctx.activeRustEditor; + if (!editor) { + return; + } + const request: JoinLinesParams = { + range: ctx.client.code2ProtocolConverter.asRange(editor.selection), + textDocument: { uri: editor.document.uri.toString() }, + }; + const change = await ctx.client.sendRequest( + 'rust-analyzer/joinLines', + request, + ); + await applySourceChange(change); + } +} + interface JoinLinesParams { textDocument: TextDocumentIdentifier; range: Range; } - -export async function handle() { - const editor = vscode.window.activeTextEditor; - if (editor == null || editor.document.languageId !== 'rust') { - return; - } - const request: JoinLinesParams = { - range: Server.client.code2ProtocolConverter.asRange(editor.selection), - textDocument: { uri: editor.document.uri.toString() }, - }; - const change = await Server.client.sendRequest( - 'rust-analyzer/joinLines', - request, - ); - await applySourceChange(change); -} -- cgit v1.2.3