aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorivan770 <[email protected]>2021-03-16 14:57:14 +0000
committerivan770 <[email protected]>2021-03-18 09:22:27 +0000
commita154ef7ca1010b890e7dbe913d00140ed029945c (patch)
tree4f077e645da76b97e25159dac77de0d0d4f7c909 /editors
parent7d604584954660d255ad0929d3be8ce03f879d0c (diff)
Remove movable array, improve client code
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/commands.ts6
-rw-r--r--editors/code/src/lsp_ext.ts2
2 files changed, 6 insertions, 2 deletions
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 {
148 const client = ctx.client; 148 const client = ctx.client;
149 if (!editor || !client) return; 149 if (!editor || !client) return;
150 150
151 const edit: lc.TextDocumentEdit = await client.sendRequest(ra.moveItem, { 151 const edit = await client.sendRequest(ra.moveItem, {
152 range: client.code2ProtocolConverter.asRange(editor.selection), 152 range: client.code2ProtocolConverter.asRange(editor.selection),
153 textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document), 153 textDocument: ctx.client.code2ProtocolConverter.asTextDocumentIdentifier(editor.document),
154 direction 154 direction
155 }); 155 });
156 156
157 if(!edit) return;
158
157 await editor.edit((builder) => { 159 await editor.edit((builder) => {
158 client.protocol2CodeConverter.asTextEdits(edit.edits).forEach((edit: any) => { 160 client.protocol2CodeConverter.asTextEdits(edit.edits).forEach((edit: any) => {
159 builder.replace(edit.range, edit.newText); 161 builder.replace(edit.range, edit.newText);
160 }); 162 });
163 }).then(() => {
164 editor.selection = new vscode.Selection(editor.selection.end, editor.selection.end);
161 }); 165 });
162 }; 166 };
163} 167}
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 {
128 textDocument: lc.TextDocumentIdentifier; 128 textDocument: lc.TextDocumentIdentifier;
129} 129}
130 130
131export const moveItem = new lc.RequestType<MoveItemParams, lc.TextDocumentEdit, void>("experimental/moveItem"); 131export const moveItem = new lc.RequestType<MoveItemParams, lc.TextDocumentEdit | void, void>("experimental/moveItem");
132 132
133export interface MoveItemParams { 133export interface MoveItemParams {
134 textDocument: lc.TextDocumentIdentifier, 134 textDocument: lc.TextDocumentIdentifier,