@@ -11,13 +11,16 @@ import { getNxCloudStatus } from '@nx-console/vscode-nx-workspace';
11
11
import { outputLogger } from '@nx-console/vscode-output-channels' ;
12
12
import { getTelemetry } from '@nx-console/vscode-telemetry' ;
13
13
import { getWorkspacePath , GitExtension } from '@nx-console/vscode-utils' ;
14
+ import { unlink , writeFile } from 'fs/promises' ;
15
+ import { tmpdir } from 'os' ;
14
16
import { join } from 'path' ;
15
17
import { xhr } from 'request-light' ;
16
18
import {
17
19
commands ,
18
20
EventEmitter ,
19
21
ExtensionContext ,
20
22
extensions ,
23
+ Tab ,
21
24
Uri ,
22
25
ViewColumn ,
23
26
WebviewPanel ,
@@ -27,8 +30,6 @@ import {
27
30
import { ActorRef , EventObject } from 'xstate' ;
28
31
import { DiffContentProvider , parseGitDiff } from './diffs/diff-provider' ;
29
32
import { createUnifiedDiffView } from './nx-cloud-fix-tree-item' ;
30
- import { unlink , writeFile } from 'fs/promises' ;
31
- import { tmpdir } from 'os' ;
32
33
33
34
export interface NxCloudFixDetails {
34
35
cipe : CIPEInfo ;
@@ -110,10 +111,13 @@ export class NxCloudFixWebview {
110
111
} ,
111
112
) ;
112
113
113
- this . webviewPanel . onDidDispose ( ( ) => {
114
+ this . webviewPanel . onDidDispose ( async ( ) => {
114
115
this . webviewPanel = undefined ;
115
116
this . currentFixDetails = undefined ;
116
117
this . _onDispose . fire ( ) ;
118
+
119
+ // Close the diff tab associated with this fix
120
+ await closeCloudFixDiffTab ( ) ;
117
121
} ) ;
118
122
119
123
this . webviewPanel . webview . html = this . getWebviewHtml (
@@ -567,3 +571,20 @@ async function updateSuggestedFix(
567
571
return false ;
568
572
}
569
573
}
574
+
575
+ export async function closeCloudFixDiffTab ( ) {
576
+ const diffTab = window . tabGroups . all
577
+ . flatMap ( ( g ) => g . tabs )
578
+ . find ( ( t ) => isCloudFixTab ( t ) ) ;
579
+
580
+ if ( diffTab ) {
581
+ await window . tabGroups . close ( diffTab , true ) ;
582
+ }
583
+ }
584
+
585
+ function isCloudFixTab ( tab : Tab ) : boolean {
586
+ return (
587
+ ( tab as any ) ?. input ?. textDiffs ?. [ 0 ] ?. original ?. scheme ===
588
+ 'nx-cloud-fix-before'
589
+ ) ;
590
+ }
0 commit comments