aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/join_lines.ts
blob: 7ae7b9d76011a1f8f033c0c68bd57e2d7717f42b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import * as vscode from 'vscode';

import { TextDocumentIdentifier, Range } from "vscode-languageclient";
import { Server } from '../server';
import { handle as applySourceChange, SourceChange } from './apply_source_change';

interface JoinLinesParams {
    textDocument: TextDocumentIdentifier;
    range: Range;
}

export async function handle() {
    let editor = vscode.window.activeTextEditor
    if (editor == null || editor.document.languageId != "rust") return
    let request: JoinLinesParams = {
        textDocument: { uri: editor.document.uri.toString() },
        range: Server.client.code2ProtocolConverter.asRange(editor.selection),
    }
    let change = await Server.client.sendRequest<SourceChange>("m/joinLines", request)
    await applySourceChange(change)
}