Fixing fix all not applying correct commands on edit

This commit is contained in:
Matt Bierner 2018-07-25 17:27:03 -07:00
parent 690744c3c6
commit 9e6a525723
2 changed files with 9 additions and 12 deletions

View file

@ -43,7 +43,7 @@ class ApplyCodeActionCommand implements Command {
fixName: action.fixName
});
}
return applyCodeActionCommands(this.client, action);
return applyCodeActionCommands(this.client, action.commands);
}
}
@ -86,17 +86,14 @@ class ApplyFixAllCodeAction implements Command {
};
try {
const combinedCodeFixesResponse = await this.client.execute('getCombinedCodeFix', args);
if (!combinedCodeFixesResponse.body) {
const { body } = await this.client.execute('getCombinedCodeFix', args);
if (!body) {
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);
if (combinedCodeFixesResponse.command) {
await vscode.commands.executeCommand(ApplyCodeActionCommand.ID, combinedCodeFixesResponse.command);
}
await applyCodeActionCommands(this.client, body.commands);
} catch {
// noop
}

View file

@ -27,15 +27,15 @@ export async function applyCodeAction(
return false;
}
}
return applyCodeActionCommands(client, action);
return applyCodeActionCommands(client, action.commands);
}
export async function applyCodeActionCommands(
client: ITypeScriptServiceClient,
action: Proto.CodeAction
commands: ReadonlyArray<{}> | undefined
): Promise<boolean> {
if (action.commands && action.commands.length) {
for (const command of action.commands) {
if (commands && commands.length) {
for (const command of commands) {
const response = await client.execute('applyCodeActionCommand', { command });
if (!response || !response.body) {
return false;