Don't return js/ts fix all for empty edits

This commit is contained in:
Matt Bierner 2019-11-14 11:46:13 -08:00
parent 230baa7372
commit 738d85a51e

View file

@ -82,6 +82,10 @@ class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {
return undefined;
}
const { edit, fixedDiagnostics } = autoFixResponse;
if (!edit.size) {
return undefined;
}
const codeAction = new vscode.CodeAction(
localize('autoFix.label', 'Auto fix'),
TypeScriptAutoFixProvider.kind);
@ -105,11 +109,11 @@ class TypeScriptAutoFixProvider implements vscode.CodeActionProvider {
};
const response = await this.client.execute('getCodeFixes', args, token);
if (response.type !== 'response' || !response.body || response.body.length > 1) {
return undefined;
continue;
}
const fix = response.body[0];
if (new Set<string>(['fixClassIncorrectlyImplementsInterface', 'spelling']).has(fix.fixName)) {
if (['fixClassIncorrectlyImplementsInterface', 'spelling'].includes(fix.fixName)) {
typeConverters.WorkspaceEdit.withFileCodeEdits(edit, this.client, fix.changes);
fixedDiagnostics.push(diagnostic);
}