Unify save and save_as for local worktrees

This fixes state propagation bugs due to missing RPC calls in save_as.
This commit is contained in:
Max Brunsfeld 2023-02-17 17:08:28 -08:00
parent 3a7cfc3901
commit cdf64b6cad
3 changed files with 42 additions and 41 deletions

View file

@ -1451,7 +1451,7 @@ impl Project {
let worktree = file.worktree.clone();
let path = file.path.clone();
worktree.update(cx, |worktree, cx| match worktree {
Worktree::Local(worktree) => worktree.save_buffer(buffer, path, cx),
Worktree::Local(worktree) => worktree.save_buffer(buffer, path, false, cx),
Worktree::Remote(worktree) => worktree.save_buffer(buffer, cx),
})
}
@ -1474,7 +1474,9 @@ impl Project {
let (worktree, path) = worktree_task.await?;
worktree
.update(&mut cx, |worktree, cx| match worktree {
Worktree::Local(worktree) => worktree.save_buffer_as(buffer.clone(), path, cx),
Worktree::Local(worktree) => {
worktree.save_buffer(buffer.clone(), path.into(), true, cx)
}
Worktree::Remote(_) => panic!("cannot remote buffers as new files"),
})
.await?;