From c4733f91c86a0aaeb2f5c122fc13512f6ea911fb Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 14 Aug 2019 14:49:23 -0700 Subject: [PATCH] Still show fix all actions for fix-all actions that can fix multiple errors with multple different diagnostics --- .../src/features/quickFix.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/extensions/typescript-language-features/src/features/quickFix.ts b/extensions/typescript-language-features/src/features/quickFix.ts index 6ce9f199704..7bc5d43f0eb 100644 --- a/extensions/typescript-language-features/src/features/quickFix.ts +++ b/extensions/typescript-language-features/src/features/quickFix.ts @@ -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([ + // Missing async + [2339, 2339], + [2345, 2339], +]); + + const preferredFixes = new Set([ 'annotateWithTypeFromJSDoc', 'constructorForDerivedNeedSuperCall',