mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 03:14:30 +00:00
Remove movable array, improve client code
This commit is contained in:
parent
7d60458495
commit
a154ef7ca1
3 changed files with 14 additions and 30 deletions
|
@ -148,16 +148,20 @@ export function moveItem(ctx: Ctx, direction: ra.Direction): Cmd {
|
|||
const client = ctx.client;
|
||||
if (!editor || !client) return;
|
||||
|
||||
const edit: lc.TextDocumentEdit = await client.sendRequest(ra.moveItem, {
|
||||
const edit = await client.sendRequest(ra.moveItem, {
|
||||
range: client.code2ProtocolConverter.asRange(editor.selection),
|
||||
textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
|
||||
direction
|
||||
});
|
||||
|
||||
if(!edit) return;
|
||||
|
||||
await editor.edit((builder) => {
|
||||
client.protocol2CodeConverter.asTextEdits(edit.edits).forEach((edit: any) => {
|
||||
builder.replace(edit.range, edit.newText);
|
||||
});
|
||||
}).then(() => {
|
||||
editor.selection = new vscode.Selection(editor.selection.end, editor.selection.end);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -128,7 +128,7 @@ export interface OpenCargoTomlParams {
|
|||
textDocument: lc.TextDocumentIdentifier;
|
||||
}
|
||||
|
||||
export const moveItem = new lc.RequestType<MoveItemParams, lc.TextDocumentEdit, void>("experimental/moveItem");
|
||||
export const moveItem = new lc.RequestType<MoveItemParams, lc.TextDocumentEdit | void, void>("experimental/moveItem");
|
||||
|
||||
export interface MoveItemParams {
|
||||
textDocument: lc.TextDocumentIdentifier,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue