Skip to content

Commit

Permalink
Merge pull request jest-community#174 from erikns/master
Browse files Browse the repository at this point in the history
Remove diagnostics for deleted files
  • Loading branch information
orta authored Nov 18, 2017
2 parents 0dae7b5 + c0fd3b8 commit 3565664
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* vscode inspector via the DiagnosticsCollection.
*/
import * as vscode from 'vscode'
import { existsSync } from 'fs'
// import { DiagnosticCollection, Uri, Diagnostic, Range, DiagnosticSeverity } from 'vscode'
import { TestFileAssertionStatus } from 'jest-editor-support'
import { TestReconciliationState } from './TestReconciliationState'
Expand Down Expand Up @@ -45,7 +46,6 @@ export function updateDiagnostics(testResults: TestFileAssertionStatus[], diagno

testResults.forEach(result => {
const uri = vscode.Uri.file(result.file)

switch (result.status) {
case TestReconciliationState.KnownFail:
if (result.assertions.length <= 0) {
Expand All @@ -59,6 +59,17 @@ export function updateDiagnostics(testResults: TestFileAssertionStatus[], diagno
break
}
})

// Remove diagnostics for files no longer in existence
const toBeDeleted = []
diagnostics.forEach(uri => {
if (!existsSync(uri.fsPath)) {
toBeDeleted.push(uri)
}
})
toBeDeleted.forEach(uri => {
diagnostics.delete(uri)
})
}

export function resetDiagnostics(diagnostics: vscode.DiagnosticCollection) {
Expand Down

0 comments on commit 3565664

Please sign in to comment.