Skip to content

Commit

Permalink
fix: reset the watcher when "resfresh tests" is triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Oct 12, 2024
1 parent ccef4f8 commit b9a3368
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/testTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export class TestTree extends vscode.Disposable {
this.fileItems.clear()
this.flatTestItems.clear()
this.testItemsByFile.clear()
this.watcher.dispose()
})
this.watcher = new ExtensionWatcher(this)
}
Expand All @@ -50,7 +51,7 @@ export class TestTree extends vscode.Disposable {
this.testItemsByFile.clear()
this.fileItems.clear()
this.flatTestItems.clear()
this.watcher.dispose()
this.watcher.reset()

this.loaderItem.busy = true

Expand Down
12 changes: 9 additions & 3 deletions src/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@ export class ExtensionWatcher extends vscode.Disposable {

constructor(private readonly testTree: TestTree) {
super(() => {
this.watcherByFolder.forEach(x => x.dispose())
this.watcherByFolder.clear()
this.reset()
log.verbose?.('[VSCODE] Watcher disposed')
})
}

reset() {
this.watcherByFolder.forEach(x => x.dispose())
this.watcherByFolder.clear()
}

watchTestFilesInWorkspace(api: VitestFolderAPI) {
if (this.watcherByFolder.has(api.workspaceFolder))
if (this.watcherByFolder.has(api.workspaceFolder)) {
return
}

const pattern = getConfig(api.workspaceFolder).filesWatcherInclude
log.info('[VSCODE] Watching', api.workspaceFolder.name, 'with pattern', pattern)
Expand Down

0 comments on commit b9a3368

Please sign in to comment.