mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 21:54:42 +00:00
Merge #7070
7070: Use applySnippetWorkspaceEdit again for actions, allow it to create files r=matklad a=Veykril Fixes #7037 Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
386c447038
1 changed files with 8 additions and 2 deletions
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue