You will need to update the following function to detect first the complete task (Main task + Body + SubTasks) and then replace this with the empty charater.
export const deleteTaskFromFile = (task: Task) => {
const basePath = (window as any).app.vault.adapter.basePath;
const filePath = path.join(basePath, task.filePath);
try {
const fileContent = fs.readFileSync(filePath, "utf8");
// Updated regex to match the task body ending with '|'
const taskRegex = new RegExp(`^- \\[ \\] ${task.body} \\|.*`, "gm");
const newContent = fileContent.replace(taskRegex, ""); // Remove the matched line from the file
fs.writeFileSync(filePath, newContent);
} catch (error) {
console.error("Error deleting task from file:", error);
}
};
You will need to update the following function to detect first the complete task (Main task + Body + SubTasks) and then replace this with the empty charater.