From 8103ac12bfc596f0f32f041239e0e26f9c2ee4cc Mon Sep 17 00:00:00 2001 From: Stanislav Alekseev <43210583+WeetHet@users.noreply.github.com> Date: Fri, 20 Sep 2024 06:36:50 +0300 Subject: [PATCH] ssh-remoting: Tidy up the code a bit after #18094 (#18102) Release Notes: - N/A --- crates/client/src/client.rs | 2 +- crates/project/src/worktree_store.rs | 7 ++++--- crates/remote/src/ssh_session.rs | 2 +- crates/rpc/src/proto_client.rs | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index a8387f7c5a..48bd646d8a 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -1622,7 +1622,7 @@ impl ProtoClient for Client { &self.handler_set } - fn goes_via_collab(&self) -> bool { + fn is_via_collab(&self) -> bool { true } } diff --git a/crates/project/src/worktree_store.rs b/crates/project/src/worktree_store.rs index 7fae8b9e1d..5c3b2a00a9 100644 --- a/crates/project/src/worktree_store.rs +++ b/crates/project/src/worktree_store.rs @@ -313,9 +313,10 @@ impl WorktreeStore { }) } + #[track_caller] pub fn add(&mut self, worktree: &Model, cx: &mut ModelContext) { let worktree_id = worktree.read(cx).id(); - debug_assert!(!self.worktrees().any(|w| w.read(cx).id() == worktree_id)); + debug_assert!(self.worktrees().all(|w| w.read(cx).id() != worktree_id)); let push_strong_handle = self.retain_worktrees || worktree.read(cx).is_visible(); let handle = if push_strong_handle { @@ -487,7 +488,7 @@ impl WorktreeStore { }; // collab has bad concurrency guarantees, so we send requests in serial. - let update_project = if downstream_client.goes_via_collab() { + let update_project = if downstream_client.is_via_collab() { Some(downstream_client.request(update)) } else { downstream_client.send(update).log_err(); @@ -508,7 +509,7 @@ impl WorktreeStore { move |update| { let client = client.clone(); async move { - if client.goes_via_collab() { + if client.is_via_collab() { client.request(update).map(|result| result.is_ok()).await } else { client.send(update).is_ok() diff --git a/crates/remote/src/ssh_session.rs b/crates/remote/src/ssh_session.rs index 10608b74f3..2bd18aa37e 100644 --- a/crates/remote/src/ssh_session.rs +++ b/crates/remote/src/ssh_session.rs @@ -471,7 +471,7 @@ impl ProtoClient for SshSession { &self.state } - fn goes_via_collab(&self) -> bool { + fn is_via_collab(&self) -> bool { false } } diff --git a/crates/rpc/src/proto_client.rs b/crates/rpc/src/proto_client.rs index 89ef580cdf..8809910276 100644 --- a/crates/rpc/src/proto_client.rs +++ b/crates/rpc/src/proto_client.rs @@ -28,7 +28,7 @@ pub trait ProtoClient: Send + Sync { fn message_handler_set(&self) -> &parking_lot::Mutex; - fn goes_via_collab(&self) -> bool; + fn is_via_collab(&self) -> bool; } #[derive(Default)] @@ -141,8 +141,8 @@ impl AnyProtoClient { Self(client) } - pub fn goes_via_collab(&self) -> bool { - self.0.goes_via_collab() + pub fn is_via_collab(&self) -> bool { + self.0.is_via_collab() } pub fn request(