mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-19 10:29:35 +03:00
Mark FileHandle
as not deleted right after saving it
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
e72a309734
commit
de6376ca80
@ -194,7 +194,9 @@ impl Worktree {
|
|||||||
content: BufferSnapshot,
|
content: BufferSnapshot,
|
||||||
ctx: &AppContext,
|
ctx: &AppContext,
|
||||||
) -> Task<Result<()>> {
|
) -> Task<Result<()>> {
|
||||||
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 {
|
ctx.background_executor().spawn(async move {
|
||||||
let buffer_size = content.text_summary().bytes.min(10 * 1024);
|
let buffer_size = content.text_summary().bytes.min(10 * 1024);
|
||||||
let file = std::fs::File::create(&abs_path)?;
|
let file = std::fs::File::create(&abs_path)?;
|
||||||
@ -203,6 +205,11 @@ impl Worktree {
|
|||||||
writer.write(chunk.as_bytes())?;
|
writer.write(chunk.as_bytes())?;
|
||||||
}
|
}
|
||||||
writer.flush()?;
|
writer.flush()?;
|
||||||
|
|
||||||
|
if let Some(handle) = handles.lock().get(path.as_path()).and_then(Weak::upgrade) {
|
||||||
|
handle.lock().is_deleted = false;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user