aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
Diffstat (limited to 'editors/code')
-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,