From f1587fbb6e5fa473446b0e405ce835e076b924e7 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 23 Jun 2021 17:32:05 +0200 Subject: [PATCH] Make `replica_id` optional in `OpenWorktreeResponse` --- zed-rpc/proto/zed.proto | 2 +- zed/src/workspace.rs | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/zed-rpc/proto/zed.proto b/zed-rpc/proto/zed.proto index 879c9766cc..d07f639044 100644 --- a/zed-rpc/proto/zed.proto +++ b/zed-rpc/proto/zed.proto @@ -43,7 +43,7 @@ message OpenWorktree { message OpenWorktreeResponse { Worktree worktree = 1; - uint32 replica_id = 2; + optional uint32 replica_id = 2; } message AddGuest { diff --git a/zed/src/workspace.rs b/zed/src/workspace.rs index 04819a09e6..6ae6f43229 100644 --- a/zed/src/workspace.rs +++ b/zed/src/workspace.rs @@ -766,12 +766,21 @@ impl Workspace { let worktree = open_worktree_response .worktree .ok_or_else(|| anyhow!("empty worktree"))?; - let replica_id = open_worktree_response.replica_id as ReplicaId; + let replica_id = open_worktree_response + .replica_id + .ok_or_else(|| anyhow!("empty replica id"))?; let worktree_id = worktree_id.try_into().unwrap(); this.update(&mut cx, |workspace, cx| { let worktree = cx.add_model(|cx| { - Worktree::remote(worktree_id, worktree, rpc, connection_id, replica_id, cx) + Worktree::remote( + worktree_id, + worktree, + rpc, + connection_id, + replica_id as ReplicaId, + cx, + ) }); cx.observe_model(&worktree, |_, _, cx| cx.notify()); workspace.worktrees.insert(worktree);