@@ -2336,29 +2336,19 @@ namespace FourSlash {
2336
2336
* @param fileName Path to file where error should be retrieved from.
2337
2337
*/
2338
2338
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
+ } ) ) ;
2351
2344
2345
+ return ts . flatMap ( ts . deduplicate ( diagnosticsForCodeFix , ts . equalOwnProperties ) , diagnostic => {
2352
2346
if ( errorCode && errorCode !== diagnostic . code ) {
2353
- continue ;
2347
+ return ;
2354
2348
}
2355
2349
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
+ } ) ;
2362
2352
}
2363
2353
2364
2354
private applyCodeActions ( actions : ts . CodeAction [ ] , index ?: number ) : void {
@@ -2389,7 +2379,7 @@ namespace FourSlash {
2389
2379
2390
2380
const codeFixes = this . getCodeFixActions ( this . activeFile . fileName , errorCode ) ;
2391
2381
2392
- if ( ! codeFixes || codeFixes . length === 0 ) {
2382
+ if ( codeFixes . length === 0 ) {
2393
2383
if ( expectedTextArray . length !== 0 ) {
2394
2384
this . raiseError ( "No codefixes returned." ) ;
2395
2385
}
@@ -2718,11 +2708,11 @@ namespace FourSlash {
2718
2708
public verifyCodeFixAvailable ( negative : boolean ) {
2719
2709
const codeFix = this . getCodeFixActions ( this . activeFile . fileName ) ;
2720
2710
2721
- if ( negative && codeFix ) {
2711
+ if ( negative && codeFix . length ) {
2722
2712
this . raiseError ( `verifyCodeFixAvailable failed - expected no fixes but found one.` ) ;
2723
2713
}
2724
2714
2725
- if ( ! ( negative || codeFix ) ) {
2715
+ if ( ! ( negative || codeFix . length ) ) {
2726
2716
this . raiseError ( `verifyCodeFixAvailable failed - expected code fixes but none found.` ) ;
2727
2717
}
2728
2718
}
0 commit comments