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.ts46
1 files changed, 22 insertions, 24 deletions
diff --git a/editors/code/src/commands/join_lines.ts b/editors/code/src/commands/join_lines.ts
index 134ddc801..7b08c3255 100644
--- a/editors/code/src/commands/join_lines.ts
+++ b/editors/code/src/commands/join_lines.ts
@@ -1,29 +1,27 @@
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 const client = ctx.client;
10 if (!editor || !client) return;
14 11
15export async function handle() { 12 const request: JoinLinesParams = {
16 const editor = vscode.window.activeTextEditor; 13 range: client.code2ProtocolConverter.asRange(editor.selection),
17 if (editor == null || editor.document.languageId !== 'rust') { 14 textDocument: { uri: editor.document.uri.toString() },
18 return; 15 };
19 } 16 const change = await client.sendRequest<SourceChange>(
20 const request: JoinLinesParams = { 17 'rust-analyzer/joinLines',
21 range: Server.client.code2ProtocolConverter.asRange(editor.selection), 18 request,
22 textDocument: { uri: editor.document.uri.toString() }, 19 );
20 await applySourceChange(ctx, change);
23 }; 21 };
24 const change = await Server.client.sendRequest<SourceChange>( 22}
25 'rust-analyzer/joinLines', 23
26 request, 24interface JoinLinesParams {
27 ); 25 textDocument: lc.TextDocumentIdentifier;
28 await applySourceChange(change); 26 range: lc.Range;
29} 27}