Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add ZED_ALWAYS_ACTIVE env var, use it in local collaboration script

Max Brunsfeld555c9847d448
diff --git a/crates/call/src/call.rs b/crates/call/src/call.rs
index bdc402ee77b..ca0d06beb6a 100644
--- a/crates/call/src/call.rs
+++ b/crates/call/src/call.rs
@@ -6,7 +6,10 @@ use anyhow::{anyhow, Result};
use audio::Audio;
use call_settings::CallSettings;
use channel::ChannelId;
-use client::{proto, ClickhouseEvent, Client, TelemetrySettings, TypedEnvelope, User, UserStore};
+use client::{
+ proto, ClickhouseEvent, Client, TelemetrySettings, TypedEnvelope, User, UserStore,
+ ZED_ALWAYS_ACTIVE,
+};
use collections::HashSet;
use futures::{future::Shared, FutureExt};
use gpui::{
@@ -356,12 +359,13 @@ impl ActiveCall {
project: Option<&ModelHandle<Project>>,
cx: &mut ModelContext<Self>,
) -> Task<Result<()>> {
- self.location = project.map(|project| project.downgrade());
- if let Some((room, _)) = self.room.as_ref() {
- room.update(cx, |room, cx| room.set_location(project, cx))
- } else {
- Task::ready(Ok(()))
+ if project.is_some() || !*ZED_ALWAYS_ACTIVE {
+ self.location = project.map(|project| project.downgrade());
+ if let Some((room, _)) = self.room.as_ref() {
+ return room.update(cx, |room, cx| room.set_location(project, cx));
+ }
}
+ Task::ready(Ok(()))
}
fn set_room(
diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs
index d28c1ab1a9b..5eae700404c 100644
--- a/crates/client/src/client.rs
+++ b/crates/client/src/client.rs
@@ -62,6 +62,8 @@ lazy_static! {
.and_then(|v| v.parse().ok());
pub static ref ZED_APP_PATH: Option<PathBuf> =
std::env::var("ZED_APP_PATH").ok().map(PathBuf::from);
+ pub static ref ZED_ALWAYS_ACTIVE: bool =
+ std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| e.len() > 0);
}
pub const ZED_SECRET_CLIENT_TOKEN: &str = "618033988749894";
diff --git a/script/start-local-collaboration b/script/start-local-collaboration
index a5836ff776a..0c4e60f9c3d 100755
--- a/script/start-local-collaboration
+++ b/script/start-local-collaboration
@@ -44,6 +44,7 @@ position_2=${half_width},${y}
# Authenticate using the collab server's admin secret.
export ZED_STATELESS=1
+export ZED_ALWAYS_ACTIVE=1
export ZED_ADMIN_API_TOKEN=secret
export ZED_SERVER_URL=http://localhost:8080
export ZED_WINDOW_SIZE=${half_width},${height}