From a154ef7ca1010b890e7dbe913d00140ed029945c Mon Sep 17 00:00:00 2001 From: ivan770 Date: Tue, 16 Mar 2021 16:57:14 +0200 Subject: Remove movable array, improve client code --- editors/code/src/commands.ts | 6 +++++- editors/code/src/lsp_ext.ts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'editors') diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts index cc90fe889..ad0b533b9 100644 --- a/editors/code/src/commands.ts +++ b/editors/code/src/commands.ts @@ -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); }); }; } diff --git a/editors/code/src/lsp_ext.ts b/editors/code/src/lsp_ext.ts index 9af30cfdb..4c070beb0 100644 --- a/editors/code/src/lsp_ext.ts +++ b/editors/code/src/lsp_ext.ts @@ -128,7 +128,7 @@ export interface OpenCargoTomlParams { textDocument: lc.TextDocumentIdentifier; } -export const moveItem = new lc.RequestType("experimental/moveItem"); +export const moveItem = new lc.RequestType("experimental/moveItem"); export interface MoveItemParams { textDocument: lc.TextDocumentIdentifier, -- cgit v1.2.3