Remoting: Fix opening multiple folders on one server (#20281)

Release Notes:

- Remoting: Fix opening multiple folders on one server
This commit is contained in:
Conrad Irwin 2024-11-05 22:16:38 -07:00 committed by GitHub
parent cfce6a8fbf
commit 846aec701f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View file

@ -386,7 +386,7 @@ impl RemoteServerProjects {
let ssh_prompt = cx.new_view(|cx| SshPrompt::new(&connection_options, cx)); let ssh_prompt = cx.new_view(|cx| SshPrompt::new(&connection_options, cx));
let connection = connect_over_ssh( let connection = connect_over_ssh(
ConnectionIdentifier::Setup, ConnectionIdentifier::setup(),
connection_options.clone(), connection_options.clone(),
ssh_prompt.clone(), ssh_prompt.clone(),
cx, cx,
@ -477,7 +477,7 @@ impl RemoteServerProjects {
.clone(); .clone();
let connect = connect_over_ssh( let connect = connect_over_ssh(
ConnectionIdentifier::Setup, ConnectionIdentifier::setup(),
connection_options.clone(), connection_options.clone(),
prompt, prompt,
cx, cx,

View file

@ -40,7 +40,7 @@ use std::{
ops::ControlFlow, ops::ControlFlow,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::{ sync::{
atomic::{AtomicU32, Ordering::SeqCst}, atomic::{AtomicU32, AtomicU64, Ordering::SeqCst},
Arc, Weak, Arc, Weak,
}, },
time::{Duration, Instant}, time::{Duration, Instant},
@ -484,11 +484,16 @@ impl EventEmitter<SshRemoteEvent> for SshRemoteClient {}
// Identifies the socket on the remote server so that reconnects // Identifies the socket on the remote server so that reconnects
// can re-join the same project. // can re-join the same project.
pub enum ConnectionIdentifier { pub enum ConnectionIdentifier {
Setup, Setup(u64),
Workspace(i64), Workspace(i64),
} }
static NEXT_ID: AtomicU64 = AtomicU64::new(1);
impl ConnectionIdentifier { impl ConnectionIdentifier {
pub fn setup() -> Self {
Self::Setup(NEXT_ID.fetch_add(1, SeqCst))
}
// This string gets used in a socket name, and so must be relatively short. // This string gets used in a socket name, and so must be relatively short.
// The total length of: // The total length of:
// /home/{username}/.local/share/zed/server_state/{name}/stdout.sock // /home/{username}/.local/share/zed/server_state/{name}/stdout.sock
@ -501,7 +506,7 @@ impl ConnectionIdentifier {
release_channel => format!("{}-", release_channel.dev_name()), release_channel => format!("{}-", release_channel.dev_name()),
}; };
match self { match self {
Self::Setup => format!("{identifier_prefix}setup"), Self::Setup(setup_id) => format!("{identifier_prefix}setup-{setup_id}"),
Self::Workspace(workspace_id) => { Self::Workspace(workspace_id) => {
format!("{identifier_prefix}workspace-{workspace_id}",) format!("{identifier_prefix}workspace-{workspace_id}",)
} }
@ -1079,7 +1084,7 @@ impl SshRemoteClient {
client_cx client_cx
.update(|cx| { .update(|cx| {
Self::new( Self::new(
ConnectionIdentifier::Setup, ConnectionIdentifier::setup(),
opts, opts,
rx, rx,
Arc::new(fake::Delegate), Arc::new(fake::Delegate),