mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
Move joinLines to the new Ctx
This commit is contained in:
parent
b42d3ee3cc
commit
83d2527880
3 changed files with 21 additions and 21 deletions
|
@ -1,29 +1,29 @@
|
|||
import * as vscode from 'vscode';
|
||||
|
||||
import { Range, TextDocumentIdentifier } from 'vscode-languageclient';
|
||||
import { Server } from '../server';
|
||||
import { Ctx, Cmd } from '../ctx';
|
||||
import {
|
||||
handle as applySourceChange,
|
||||
SourceChange,
|
||||
} from './apply_source_change';
|
||||
|
||||
export function joinLines(ctx: Ctx): Cmd {
|
||||
return async () => {
|
||||
const editor = ctx.activeRustEditor;
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
const request: JoinLinesParams = {
|
||||
range: ctx.client.code2ProtocolConverter.asRange(editor.selection),
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
};
|
||||
const change = await ctx.client.sendRequest<SourceChange>(
|
||||
'rust-analyzer/joinLines',
|
||||
request,
|
||||
);
|
||||
await applySourceChange(change);
|
||||
}
|
||||
}
|
||||
|
||||
interface JoinLinesParams {
|
||||
textDocument: TextDocumentIdentifier;
|
||||
range: Range;
|
||||
}
|
||||
|
||||
export async function handle() {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor == null || editor.document.languageId !== 'rust') {
|
||||
return;
|
||||
}
|
||||
const request: JoinLinesParams = {
|
||||
range: Server.client.code2ProtocolConverter.asRange(editor.selection),
|
||||
textDocument: { uri: editor.document.uri.toString() },
|
||||
};
|
||||
const change = await Server.client.sendRequest<SourceChange>(
|
||||
'rust-analyzer/joinLines',
|
||||
request,
|
||||
);
|
||||
await applySourceChange(change);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue