@@ -21,6 +21,7 @@ import configuration from "./configuration";
2121import { SwiftExecution } from "./tasks/SwiftExecution" ;
2222import { WorkspaceContext } from "./WorkspaceContext" ;
2323import { checkIfBuildComplete , lineBreakRegex } from "./utilities/tasks" ;
24+ import { validFileTypes } from "./utilities/filesystem" ;
2425
2526interface ParsedDiagnostic {
2627 uri : string ;
@@ -102,6 +103,17 @@ export class DiagnosticsManager implements vscode.Disposable {
102103 context . outputChannel . log ( `${ e } ` , 'Failed to provide "swiftc" diagnostics' )
103104 ) ;
104105 } ) ;
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+ } ) ;
105117 }
106118
107119 /**
@@ -276,6 +288,8 @@ export class DiagnosticsManager implements vscode.Disposable {
276288 this . diagnosticCollection . dispose ( ) ;
277289 this . onDidStartTaskDisposible . dispose ( ) ;
278290 this . onDidChangeConfigurationDisposible . dispose ( ) ;
291+ this . onDidDeleteDisposible . dispose ( ) ;
292+ this . workspaceFileWatcher . dispose ( ) ;
279293 }
280294
281295 private includeSwiftcDiagnostics ( ) : boolean {
@@ -454,4 +468,6 @@ export class DiagnosticsManager implements vscode.Disposable {
454468
455469 private onDidStartTaskDisposible : vscode . Disposable ;
456470 private onDidChangeConfigurationDisposible : vscode . Disposable ;
471+ private onDidDeleteDisposible : vscode . Disposable ;
472+ private workspaceFileWatcher : vscode . FileSystemWatcher ;
457473}
0 commit comments