2018-10-07 22:44:25 +02:00
|
|
|
import * as vscode from 'vscode';
|
|
|
|
|
2018-10-07 22:59:02 +02:00
|
|
|
import { Range, TextDocumentIdentifier } from 'vscode-languageclient';
|
2018-10-07 22:44:25 +02:00
|
|
|
import { Server } from '../server';
|
|
|
|
import { handle as applySourceChange, SourceChange } from './apply_source_change';
|
|
|
|
|
|
|
|
interface JoinLinesParams {
|
|
|
|
textDocument: TextDocumentIdentifier;
|
|
|
|
range: Range;
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function handle() {
|
2018-10-07 22:59:02 +02:00
|
|
|
const editor = vscode.window.activeTextEditor;
|
2018-10-08 20:18:55 +02:00
|
|
|
if (editor == null || editor.document.languageId !== 'rust') { return; }
|
2018-10-07 22:59:02 +02:00
|
|
|
const request: JoinLinesParams = {
|
2018-10-07 22:44:25 +02:00
|
|
|
range: Server.client.code2ProtocolConverter.asRange(editor.selection),
|
2018-10-07 22:59:02 +02:00
|
|
|
textDocument: { uri: editor.document.uri.toString() },
|
|
|
|
};
|
|
|
|
const change = await Server.client.sendRequest<SourceChange>('m/joinLines', request);
|
|
|
|
await applySourceChange(change);
|
2018-10-07 22:44:25 +02:00
|
|
|
}
|