aboutsummaryrefslogtreecommitdiff
path: root/editors
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
parentb42d3ee3cc22aaa892d15c4ba2219a3bc53907a1 (diff)
Move joinLines to the new Ctx
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/commands/index.ts2
-rw-r--r--editors/code/src/commands/join_lines.ts38
-rw-r--r--editors/code/src/main.ts2
3 files changed, 21 insertions, 21 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}
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index a4149a059..95beb2d8f 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -18,6 +18,7 @@ export async function activate(context: vscode.ExtensionContext) {
18 ctx.registerCommand('analyzerStatus', commands.analyzerStatus); 18 ctx.registerCommand('analyzerStatus', commands.analyzerStatus);
19 ctx.registerCommand('collectGarbage', commands.collectGarbage); 19 ctx.registerCommand('collectGarbage', commands.collectGarbage);
20 ctx.registerCommand('matchingBrace', commands.matchingBrace); 20 ctx.registerCommand('matchingBrace', commands.matchingBrace);
21 ctx.registerCommand('joinLines', commands.joinLines);
21 22
22 function disposeOnDeactivation(disposable: vscode.Disposable) { 23 function disposeOnDeactivation(disposable: vscode.Disposable) {
23 context.subscriptions.push(disposable); 24 context.subscriptions.push(disposable);
@@ -56,7 +57,6 @@ export async function activate(context: vscode.ExtensionContext) {
56 } 57 }
57 58
58 // Commands are requests from vscode to the language server 59 // Commands are requests from vscode to the language server
59 registerCommand('rust-analyzer.joinLines', commands.joinLines.handle);
60 registerCommand('rust-analyzer.parentModule', commands.parentModule.handle); 60 registerCommand('rust-analyzer.parentModule', commands.parentModule.handle);
61 registerCommand('rust-analyzer.run', commands.runnables.handle); 61 registerCommand('rust-analyzer.run', commands.runnables.handle);
62 // Unlike the above this does not send requests to the language server 62 // Unlike the above this does not send requests to the language server