Skip to content

Commit 4f27e9f

Browse files
committed
Filter tasks by existing workspace roots before saving to disk
1 parent 4b90d96 commit 4f27e9f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎apps/editor/src/utils/tasks-utils.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ export const save_all_tasks = (
2828
context: vscode.ExtensionContext,
2929
tasks: Record<string, Task[]>
3030
) => {
31+
const filtered_tasks: Record<string, Task[]> = {}
32+
33+
for (const root in tasks) {
34+
if (fs.existsSync(root)) {
35+
filtered_tasks[root] = tasks[root]
36+
}
37+
}
38+
3139
const file_path = get_tasks_file_path(context)
3240
const dir_path = path.dirname(file_path)
3341

@@ -36,7 +44,7 @@ export const save_all_tasks = (
3644
}
3745

3846
try {
39-
fs.writeFileSync(file_path, JSON.stringify(tasks, null, 2), 'utf8')
47+
fs.writeFileSync(file_path, JSON.stringify(filtered_tasks, null, 2), 'utf8')
4048
} catch (error) {
4149
console.error('Failed to save tasks', error)
4250
}

0 commit comments

Comments
 (0)