diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index fc85fb7276c03..458eaeb2c29f8 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2150,10 +2150,18 @@ namespace FourSlash { * @param fileName Path to file where error should be retrieved from. */ private getCodeFixActions(fileName: string, errorCode?: number): ts.CodeAction[] { - const diagnostics: ts.Diagnostic[] = this.getDiagnostics(fileName); + const diagnosticsForCodeFix = this.getDiagnostics(fileName).map(diagnostic => { + return { + start: diagnostic.start, + length: diagnostic.length, + code: diagnostic.code + } + }); + const dedupedDiagnositcs = ts.deduplicate(diagnosticsForCodeFix, ts.equalOwnProperties); let actions: ts.CodeAction[] = undefined; - for (const diagnostic of diagnostics) { + + for (const diagnostic of dedupedDiagnositcs) { if (errorCode && errorCode !== diagnostic.code) { continue; diff --git a/src/services/services.ts b/src/services/services.ts index b83995e31ed63..2b1d414f4c3f0 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1688,7 +1688,7 @@ namespace ts { let allFixes: CodeAction[] = []; - forEach(errorCodes, error => { + forEach(deduplicate(errorCodes), error => { cancellationToken.throwIfCancellationRequested(); const context = { diff --git a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts index 46de88f7511e4..3160a3b9a080c 100644 --- a/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts +++ b/tests/cases/fourslash/codeFixClassExtendAbstractProperty.ts @@ -2,11 +2,15 @@ //// abstract class A { //// abstract x: number; +//// abstract foo(): number; //// } //// //// class C extends A {[| //// |]} verify.rangeAfterCodeFix(` -x: number; + x: number; + foo(): number { + throw new Error('Method not implemented.'); + } `);