Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions packages/typescript-plugin/src/project-svelte-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export class ProjectSvelteFilesManager {
return;
}

this.disposeWatchersAndFiles();
this.disposeWatchers();
this.clearProjectFile();
this.parsedCommandLine = parsedCommandLine;
this.setupWatchers();
this.updateProjectSvelteFiles();
Expand Down Expand Up @@ -162,7 +163,8 @@ export class ProjectSvelteFilesManager {
}

private onConfigChanged(config: Configuration) {
this.disposeWatchersAndFiles();
this.disposeWatchers();
this.clearProjectFile();

if (config.enable) {
this.setupWatchers();
Expand All @@ -178,16 +180,23 @@ export class ProjectSvelteFilesManager {
}
}

private disposeWatchersAndFiles() {
private disposeWatchers() {
this.directoryWatchers.forEach((watcher) => watcher.close());
this.directoryWatchers.clear();
}

private clearProjectFile() {
this.projectFileToOriginalCasing.forEach((file) => this.removeFileFromProject(file));
this.projectFileToOriginalCasing.clear();
}

dispose() {
this.disposeWatchersAndFiles();
this.disposeWatchers();

// Don't remove files from the project here
// because TypeScript already does that when the project is closed
// - and because the project is closed, `project.removeFile` will result in an error
this.projectFileToOriginalCasing.clear();

ProjectSvelteFilesManager.instances.delete(this.project.getProjectName());
}
Expand Down