aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/join_lines.ts
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code/src/commands/join_lines.ts')
-rw-r--r--editors/code/src/commands/join_lines.ts45
1 files changed, 21 insertions, 24 deletions
diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts
index 134ddc801..f4f902cf9 100644
--- a/editors/code/src/commands/join_lines.ts
+++ b/editors/code/src/commands/join_lines.ts
@@ -1,29 +1,26 @@
1import * as vscode from 'vscode'; 1import * as lc from 'vscode-languageclient';
2 2
3import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; 3import { Ctx, Cmd } from '../ctx';
4import { Server } from '../server'; 4import { applySourceChange, SourceChange } from '../source_change';
5import {
6 handle as applySourceChange,
7 SourceChange,
8} from './apply_source_change';
9 5
10interface JoinLinesParams { 6export function joinLines(ctx: Ctx): Cmd {
11 textDocument: TextDocumentIdentifier; 7 return async () => {
12 range: Range; 8 const editor = ctx.activeRustEditor;
13} 9 if (!editor) return;
14 10
15export async function handle() { 11 const request: JoinLinesParams = {
16 const editor = vscode.window.activeTextEditor; 12 range: ctx.client.code2ProtocolConverter.asRange(editor.selection),
17 if (editor == null || editor.document.languageId !== 'rust') { 13 textDocument: { uri: editor.document.uri.toString() },
18 return; 14 };
19 } 15 const change = await ctx.client.sendRequest<SourceChange>(
20 const request: JoinLinesParams = { 16 'rust-analyzer/joinLines',
21 range: Server.client.code2ProtocolConverter.asRange(editor.selection), 17 request,
22 textDocument: { uri: editor.document.uri.toString() }, 18 );
19 await applySourceChange(ctx, change);
23 }; 20 };
24 const change = await Server.client.sendRequest<SourceChange>( 21}
25 'rust-analyzer/joinLines', 22
26 request, 23interface JoinLinesParams {
27 ); 24 textDocument: lc.TextDocumentIdentifier;
28 await applySourceChange(change); 25 range: lc.Range;
29} 26}