From de6376ca80fbc5cf245b7750aad2da9b6e5d1568 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 11 May 2021 17:26:26 +0200 Subject: [PATCH] Mark `FileHandle` as not deleted right after saving it Co-Authored-By: Nathan Sobo --- zed/src/worktree.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/zed/src/worktree.rs b/zed/src/worktree.rs index 1478daaff3ab11ae7614bff97ef570c5fe47c38c..be895533f123a1fcd713bf26122f1da739101e4c 100644 --- a/zed/src/worktree.rs +++ b/zed/src/worktree.rs @@ -194,7 +194,9 @@ impl Worktree { content: BufferSnapshot, ctx: &AppContext, ) -> Task> { - let abs_path = self.absolutize(path); + let handles = self.handles.clone(); + let path = path.to_path_buf(); + let abs_path = self.absolutize(&path); ctx.background_executor().spawn(async move { let buffer_size = content.text_summary().bytes.min(10 * 1024); let file = std::fs::File::create(&abs_path)?; @@ -203,6 +205,11 @@ impl Worktree { writer.write(chunk.as_bytes())?; } writer.flush()?; + + if let Some(handle) = handles.lock().get(path.as_path()).and_then(Weak::upgrade) { + handle.lock().is_deleted = false; + } + Ok(()) }) }