mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
vscode: migrate join_lines to rust-analyzer-api.ts
This commit is contained in:
parent
c9a2fa1835
commit
38d7945ec7
1 changed files with 4 additions and 13 deletions
|
@ -1,7 +1,7 @@
|
||||||
import * as lc from 'vscode-languageclient';
|
import * as ra from '../rust-analyzer-api';
|
||||||
|
|
||||||
import { Ctx, Cmd } from '../ctx';
|
import { Ctx, Cmd } from '../ctx';
|
||||||
import { applySourceChange, SourceChange } from '../source_change';
|
import { applySourceChange } from '../source_change';
|
||||||
|
|
||||||
export function joinLines(ctx: Ctx): Cmd {
|
export function joinLines(ctx: Ctx): Cmd {
|
||||||
return async () => {
|
return async () => {
|
||||||
|
@ -9,19 +9,10 @@ export function joinLines(ctx: Ctx): Cmd {
|
||||||
const client = ctx.client;
|
const client = ctx.client;
|
||||||
if (!editor || !client) return;
|
if (!editor || !client) return;
|
||||||
|
|
||||||
const request: JoinLinesParams = {
|
const change = await client.sendRequest(ra.joinLines, {
|
||||||
range: client.code2ProtocolConverter.asRange(editor.selection),
|
range: client.code2ProtocolConverter.asRange(editor.selection),
|
||||||
textDocument: { uri: editor.document.uri.toString() },
|
textDocument: { uri: editor.document.uri.toString() },
|
||||||
};
|
});
|
||||||
const change = await client.sendRequest<SourceChange>(
|
|
||||||
'rust-analyzer/joinLines',
|
|
||||||
request,
|
|
||||||
);
|
|
||||||
await applySourceChange(ctx, change);
|
await applySourceChange(ctx, change);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface JoinLinesParams {
|
|
||||||
textDocument: lc.TextDocumentIdentifier;
|
|
||||||
range: lc.Range;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue