diff options
Diffstat (limited to 'editors/code/src/commands/join_lines.ts')
-rw-r--r-- | editors/code/src/commands/join_lines.ts | 46 |
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 @@ | |||
1 | import * as vscode from 'vscode'; | 1 | import * as lc from 'vscode-languageclient'; |
2 | 2 | ||
3 | import { Range, TextDocumentIdentifier } from 'vscode-languageclient'; | 3 | import { Ctx, Cmd } from '../ctx'; |
4 | import { Server } from '../server'; | 4 | import { applySourceChange, SourceChange } from '../source_change'; |
5 | import { | ||
6 | handle as applySourceChange, | ||
7 | SourceChange, | ||
8 | } from './apply_source_change'; | ||
9 | 5 | ||
10 | interface JoinLinesParams { | 6 | export 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 | ||
15 | export 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, | 24 | interface JoinLinesParams { |
27 | ); | 25 | textDocument: lc.TextDocumentIdentifier; |
28 | await applySourceChange(change); | 26 | range: lc.Range; |
29 | } | 27 | } |