From 9e6a525723dc7e429d32e8dca918ef8320092437 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 25 Jul 2018 17:27:03 -0700 Subject: [PATCH] Fixing fix all not applying correct commands on edit --- .../src/features/quickFix.ts | 13 +++++-------- .../src/utils/codeAction.ts | 8 ++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/extensions/typescript-language-features/src/features/quickFix.ts b/extensions/typescript-language-features/src/features/quickFix.ts index a00a5ee6b11..e15edeb4b17 100644 --- a/extensions/typescript-language-features/src/features/quickFix.ts +++ b/extensions/typescript-language-features/src/features/quickFix.ts @@ -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 } diff --git a/extensions/typescript-language-features/src/utils/codeAction.ts b/extensions/typescript-language-features/src/utils/codeAction.ts index f9dec3a7d4d..e2c71edb370 100644 --- a/extensions/typescript-language-features/src/utils/codeAction.ts +++ b/extensions/typescript-language-features/src/utils/codeAction.ts @@ -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 { - 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; -- GitLab