aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/join_lines.ts
blob: de0614653d6b13d00b3bcf80db24f51153a5706a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import * as ra from '../rust-analyzer-api';

import { Ctx, Cmd } from '../ctx';
import { applySourceChange } from '../source_change';

export function joinLines(ctx: Ctx): Cmd {
    return async () => {
        const editor = ctx.activeRustEditor;
        const client = ctx.client;
        if (!editor || !client) return;

        const change = await client.sendRequest(ra.joinLines, {
            range: client.code2ProtocolConverter.asRange(editor.selection),
            textDocument: { uri: editor.document.uri.toString() },
        });
        await applySourceChange(ctx, change);
    };
}