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