From ab12d393a1769f294cab6527f3872747082221ed Mon Sep 17 00:00:00 2001 From: aaron-jack-manning Date: Tue, 30 Aug 2022 18:10:19 +1000 Subject: [PATCH] temp.md file left behind bug fixed --- src/edit.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/edit.rs b/src/edit.rs index 25a2d41..7a4c035 100755 --- a/src/edit.rs +++ b/src/edit.rs @@ -39,7 +39,8 @@ pub fn edit_info(id : Id, vault_folder : path::PathBuf, editor : &str) -> Result else { let file_contents = fs::read_to_string(&temp_path)?; - task.data.info = if file_contents.is_empty() { + // Check if the remaining file is just whitespace, so the info will become None + task.data.info = if file_contents.trim().is_empty() { None } else { @@ -48,6 +49,9 @@ pub fn edit_info(id : Id, vault_folder : path::PathBuf, editor : &str) -> Result task.save()?; + // Remove the temporary file + fs::remove_file(&temp_path)?; + Ok(()) } } @@ -108,7 +112,7 @@ pub fn edit_raw(id : Id, vault_folder : path::PathBuf, editor : &str, state : &m task.save()?; - trash::delete(&temp_path)?; + fs::remove_file(&temp_path)?; Ok(()) }