@@ -21,6 +21,7 @@ import configuration from "./configuration";
21
21
import { SwiftExecution } from "./tasks/SwiftExecution" ;
22
22
import { WorkspaceContext } from "./WorkspaceContext" ;
23
23
import { checkIfBuildComplete , lineBreakRegex } from "./utilities/tasks" ;
24
+ import { validFileTypes } from "./utilities/filesystem" ;
24
25
25
26
interface ParsedDiagnostic {
26
27
uri : string ;
@@ -102,6 +103,17 @@ export class DiagnosticsManager implements vscode.Disposable {
102
103
context . outputChannel . log ( `${ e } ` , 'Failed to provide "swiftc" diagnostics' )
103
104
) ;
104
105
} ) ;
106
+ const fileTypes = validFileTypes . join ( "," ) ;
107
+ this . workspaceFileWatcher = vscode . workspace . createFileSystemWatcher (
108
+ `**/*.{${ fileTypes } }` ,
109
+ true ,
110
+ true
111
+ ) ;
112
+ this . onDidDeleteDisposible = this . workspaceFileWatcher . onDidDelete ( uri => {
113
+ if ( this . allDiagnostics . delete ( uri . fsPath ) ) {
114
+ this . diagnosticCollection . delete ( uri ) ;
115
+ }
116
+ } ) ;
105
117
}
106
118
107
119
/**
@@ -276,6 +288,8 @@ export class DiagnosticsManager implements vscode.Disposable {
276
288
this . diagnosticCollection . dispose ( ) ;
277
289
this . onDidStartTaskDisposible . dispose ( ) ;
278
290
this . onDidChangeConfigurationDisposible . dispose ( ) ;
291
+ this . onDidDeleteDisposible . dispose ( ) ;
292
+ this . workspaceFileWatcher . dispose ( ) ;
279
293
}
280
294
281
295
private includeSwiftcDiagnostics ( ) : boolean {
@@ -454,4 +468,6 @@ export class DiagnosticsManager implements vscode.Disposable {
454
468
455
469
private onDidStartTaskDisposible : vscode . Disposable ;
456
470
private onDidChangeConfigurationDisposible : vscode . Disposable ;
471
+ private onDidDeleteDisposible : vscode . Disposable ;
472
+ private workspaceFileWatcher : vscode . FileSystemWatcher ;
457
473
}
0 commit comments