aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-12-30 14:50:15 +0000
committerAleksey Kladov <[email protected]>2019-12-30 18:07:59 +0000
commit83d2527880d86653ce00940c65620319b36afcff (patch)
tree1c20ffd305fe661b1aab9d1e0b0bbc7e05ec389c /editors/code/src/commands
parentb42d3ee3cc22aaa892d15c4ba2219a3bc53907a1 (diff)
Move joinLines to the new Ctx
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r--editors/code/src/commands/index.ts2
-rw-r--r--editors/code/src/commands/join_lines.ts38
2 files changed, 20 insertions, 20 deletions
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'
2 2
3import { analyzerStatus } from './analyzer_status'; 3import { analyzerStatus } from './analyzer_status';
4import { matchingBrace } from './matching_brace'; 4import { matchingBrace } from './matching_brace';
5import { joinLines } from './join_lines';
5import * as applySourceChange from './apply_source_change'; 6import * as applySourceChange from './apply_source_change';
6import * as expandMacro from './expand_macro'; 7import * as expandMacro from './expand_macro';
7import * as inlayHints from './inlay_hints'; 8import * as inlayHints from './inlay_hints';
8import * as joinLines from './join_lines';
9import * as onEnter from './on_enter'; 9import * as onEnter from './on_enter';
10import * as parentModule from './parent_module'; 10import * as parentModule from './parent_module';
11import * as runnables from './runnables'; 11import * 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 @@
1import * as vscode from 'vscode';
2
3import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; 1import { Range, TextDocumentIdentifier } from 'vscode-languageclient';
4import { Server } from '../server'; 2import { Ctx, Cmd } from '../ctx';
5import { 3import {
6 handle as applySourceChange, 4 handle as applySourceChange,
7 SourceChange, 5 SourceChange,
8} from './apply_source_change'; 6} from './apply_source_change';
9 7
8export function joinLines(ctx: Ctx): Cmd {
9 return async () => {
10 const editor = ctx.activeRustEditor;
11 if (!editor) {
12 return;
13 }
14 const request: JoinLinesParams = {
15 range: ctx.client.code2ProtocolConverter.asRange(editor.selection),
16 textDocument: { uri: editor.document.uri.toString() },
17 };
18 const change = await ctx.client.sendRequest<SourceChange>(
19 'rust-analyzer/joinLines',
20 request,
21 );
22 await applySourceChange(change);
23 }
24}
25
10interface JoinLinesParams { 26interface JoinLinesParams {
11 textDocument: TextDocumentIdentifier; 27 textDocument: TextDocumentIdentifier;
12 range: Range; 28 range: Range;
13} 29}
14
15export async function handle() {
16 const editor = vscode.window.activeTextEditor;
17 if (editor == null || editor.document.languageId !== 'rust') {
18 return;
19 }
20 const request: JoinLinesParams = {
21 range: Server.client.code2ProtocolConverter.asRange(editor.selection),
22 textDocument: { uri: editor.document.uri.toString() },
23 };
24 const change = await Server.client.sendRequest<SourceChange>(
25 'rust-analyzer/joinLines',
26 request,
27 );
28 await applySourceChange(change);
29}