Still show fix all actions for fix-all actions that can fix multiple errors with multple different diagnostics

This commit is contained in:
Matt Bierner
2019-08-14 14:49:23 -07:00
parent e4863753b9
commit c4733f91c8

View File

@@ -286,7 +286,12 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
}
// Make sure there are multiple diagnostics of the same type in the file
if (!this.diagnosticsManager.getDiagnostics(document.uri).some(x => x.code === diagnostic.code && x !== diagnostic)) {
if (!this.diagnosticsManager.getDiagnostics(document.uri).some(x => {
if (x === diagnostic) {
return false;
}
return x.code === diagnostic.code || fixAllErrorCodes.get(x.code as number) === diagnostic.code;
})) {
return results;
}
@@ -304,6 +309,15 @@ class TypeScriptQuickFixProvider implements vscode.CodeActionProvider {
}
}
// Some fix all actions can actually fix multiple differnt diagnostics. Make sure we still show the fix all action
// in such cases
const fixAllErrorCodes = new Map<number, number>([
// Missing async
[2339, 2339],
[2345, 2339],
]);
const preferredFixes = new Set([
'annotateWithTypeFromJSDoc',
'constructorForDerivedNeedSuperCall',