about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2020-12-29 15:43:17 +0100
committerLukas Wirth <lukastw97@gmail.com>2020-12-29 15:43:17 +0100
commit689898e4f6588a353e7c0b74a0dede8dda9c917a (patch)
tree3effe63dbbe75a0d5f8f838f3c2733839f105240
parent77ad203a719be074e81485af7a4fb02fac6cbf61 (diff)
downloadrust-689898e4f6588a353e7c0b74a0dede8dda9c917a.tar.gz
rust-689898e4f6588a353e7c0b74a0dede8dda9c917a.zip
Apply text edits manually in vscode client
-rw-r--r--editors/code/src/commands.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 9d4823a34de..b12e134ca97 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -469,8 +469,14 @@ export function resolveCodeAction(ctx: Ctx): Cmd {
         if (!item.edit) {
             return;
         }
-        const edit = client.protocol2CodeConverter.asWorkspaceEdit(item.edit);
-        await vscode.workspace.applyEdit(edit);
+        const itemEdit = item.edit;
+        const edit = client.protocol2CodeConverter.asWorkspaceEdit(itemEdit);
+        // filter out all text edits and recreate the WorkspaceEdit without them so we can apply
+        // snippet edits on our own
+        const itemEditWithoutTextEdits = { ...item, documentChanges: itemEdit.documentChanges?.filter(change => "kind" in change) };
+        const editWithoutTextEdits = client.protocol2CodeConverter.asWorkspaceEdit(itemEditWithoutTextEdits);
+        await applySnippetWorkspaceEdit(edit);
+        await vscode.workspace.applyEdit(editWithoutTextEdits);
     };
 }