提交 9e6a5257 编写于 作者: M Matt Bierner

Fixing fix all not applying correct commands on edit

上级 690744c3
...@@ -43,7 +43,7 @@ class ApplyCodeActionCommand implements Command { ...@@ -43,7 +43,7 @@ class ApplyCodeActionCommand implements Command {
fixName: action.fixName fixName: action.fixName
}); });
} }
return applyCodeActionCommands(this.client, action); return applyCodeActionCommands(this.client, action.commands);
} }
} }
...@@ -86,17 +86,14 @@ class ApplyFixAllCodeAction implements Command { ...@@ -86,17 +86,14 @@ class ApplyFixAllCodeAction implements Command {
}; };
try { try {
const combinedCodeFixesResponse = await this.client.execute('getCombinedCodeFix', args); const { body } = await this.client.execute('getCombinedCodeFix', args);
if (!combinedCodeFixesResponse.body) { if (!body) {
return; return;
} }
const edit = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, combinedCodeFixesResponse.body.changes); const edit = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, body.changes);
await vscode.workspace.applyEdit(edit); await vscode.workspace.applyEdit(edit);
await applyCodeActionCommands(this.client, body.commands);
if (combinedCodeFixesResponse.command) {
await vscode.commands.executeCommand(ApplyCodeActionCommand.ID, combinedCodeFixesResponse.command);
}
} catch { } catch {
// noop // noop
} }
......
...@@ -27,15 +27,15 @@ export async function applyCodeAction( ...@@ -27,15 +27,15 @@ export async function applyCodeAction(
return false; return false;
} }
} }
return applyCodeActionCommands(client, action); return applyCodeActionCommands(client, action.commands);
} }
export async function applyCodeActionCommands( export async function applyCodeActionCommands(
client: ITypeScriptServiceClient, client: ITypeScriptServiceClient,
action: Proto.CodeAction commands: ReadonlyArray<{}> | undefined
): Promise<boolean> { ): Promise<boolean> {
if (action.commands && action.commands.length) { if (commands && commands.length) {
for (const command of action.commands) { for (const command of commands) {
const response = await client.execute('applyCodeActionCommand', { command }); const response = await client.execute('applyCodeActionCommand', { command });
if (!response || !response.body) { if (!response || !response.body) {
return false; return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册