Preserve ordering between UpdateProject and CreateBufferForPeer messages

Previously, because UpdateProject messages were sent in a separately-
spawned task, they could be sent after CreateBufferForPeer messages that
were intended to be sent after them.

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
Max Brunsfeld 2023-04-10 12:40:09 -07:00
parent 9761febf82
commit e79815622c
3 changed files with 117 additions and 129 deletions

View file

@ -1305,10 +1305,8 @@ impl Workspace {
RemoveWorktreeFromProject(worktree_id): &RemoveWorktreeFromProject,
cx: &mut ViewContext<Self>,
) {
let future = self
.project
self.project
.update(cx, |project, cx| project.remove_worktree(*worktree_id, cx));
cx.foreground().spawn(future).detach();
}
fn project_path_for_path(
@ -3266,9 +3264,7 @@ mod tests {
);
// Remove a project folder
project
.update(cx, |project, cx| project.remove_worktree(worktree_id, cx))
.await;
project.update(cx, |project, cx| project.remove_worktree(worktree_id, cx));
assert_eq!(
cx.current_window_title(window_id).as_deref(),
Some("one.txt — root2")