mirror of
https://github.com/Microsoft/vscode
synced 2024-10-30 06:38:23 +00:00
Fixing fix all not applying correct commands on edit
This commit is contained in:
parent
690744c3c6
commit
9e6a525723
2 changed files with 9 additions and 12 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue