@@ -2336,29 +2336,19 @@ namespace FourSlash {
23362336 * @param fileName Path to file where error should be retrieved from.
23372337 */
23382338 private getCodeFixActions ( fileName : string , errorCode ?: number ) : ts . CodeAction [ ] {
2339- const diagnosticsForCodeFix = this . getDiagnostics ( fileName ) . map ( diagnostic => {
2340- return {
2341- start : diagnostic . start ,
2342- length : diagnostic . length ,
2343- code : diagnostic . code
2344- } ;
2345- } ) ;
2346- const dedupedDiagnositcs = ts . deduplicate ( diagnosticsForCodeFix , ts . equalOwnProperties ) ;
2347-
2348- let actions : ts . CodeAction [ ] = undefined ;
2349-
2350- for ( const diagnostic of dedupedDiagnositcs ) {
2339+ const diagnosticsForCodeFix = this . getDiagnostics ( fileName ) . map ( diagnostic => ( {
2340+ start : diagnostic . start ,
2341+ length : diagnostic . length ,
2342+ code : diagnostic . code
2343+ } ) ) ;
23512344
2345+ return ts . flatMap ( ts . deduplicate ( diagnosticsForCodeFix , ts . equalOwnProperties ) , diagnostic => {
23522346 if ( errorCode && errorCode !== diagnostic . code ) {
2353- continue ;
2347+ return ;
23542348 }
23552349
2356- const newActions = this . languageService . getCodeFixesAtPosition ( fileName , diagnostic . start , diagnostic . start + diagnostic . length , [ diagnostic . code ] , this . formatCodeSettings ) ;
2357- if ( newActions && newActions . length ) {
2358- actions = actions ? actions . concat ( newActions ) : newActions ;
2359- }
2360- }
2361- return actions ;
2350+ return this . languageService . getCodeFixesAtPosition ( fileName , diagnostic . start , diagnostic . start + diagnostic . length , [ diagnostic . code ] , this . formatCodeSettings ) ;
2351+ } ) ;
23622352 }
23632353
23642354 private applyCodeActions ( actions : ts . CodeAction [ ] , index ?: number ) : void {
@@ -2389,7 +2379,7 @@ namespace FourSlash {
23892379
23902380 const codeFixes = this . getCodeFixActions ( this . activeFile . fileName , errorCode ) ;
23912381
2392- if ( ! codeFixes || codeFixes . length === 0 ) {
2382+ if ( codeFixes . length === 0 ) {
23932383 if ( expectedTextArray . length !== 0 ) {
23942384 this . raiseError ( "No codefixes returned." ) ;
23952385 }
@@ -2718,11 +2708,11 @@ namespace FourSlash {
27182708 public verifyCodeFixAvailable ( negative : boolean ) {
27192709 const codeFix = this . getCodeFixActions ( this . activeFile . fileName ) ;
27202710
2721- if ( negative && codeFix ) {
2711+ if ( negative && codeFix . length ) {
27222712 this . raiseError ( `verifyCodeFixAvailable failed - expected no fixes but found one.` ) ;
27232713 }
27242714
2725- if ( ! ( negative || codeFix ) ) {
2715+ if ( ! ( negative || codeFix . length ) ) {
27262716 this . raiseError ( `verifyCodeFixAvailable failed - expected code fixes but none found.` ) ;
27272717 }
27282718 }
0 commit comments