open new buffer (#11203)

Release Notes:

- Allow creating new untitled buffers in remote projects

TODO:
- Add a Test
- Fix version number check
This commit is contained in:
Conrad Irwin 2024-04-30 16:09:43 -06:00 committed by GitHub
parent 28bcc95468
commit 3752ed294d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 276 additions and 111 deletions

View file

@ -21,7 +21,7 @@ struct ConnectedPrincipal {
connection_ids: HashSet<ConnectionId>,
}
#[derive(Debug, Serialize)]
#[derive(Copy, Clone, Debug, Serialize, PartialOrd, PartialEq, Eq, Ord)]
pub struct ZedVersion(pub SemanticVersion);
impl fmt::Display for ZedVersion {
@ -34,6 +34,32 @@ impl ZedVersion {
pub fn can_collaborate(&self) -> bool {
self.0 >= SemanticVersion::new(0, 129, 2)
}
pub fn with_save_as() -> ZedVersion {
ZedVersion(SemanticVersion::new(0, 134, 0))
}
}
pub trait VersionedMessage {
fn required_host_version(&self) -> Option<ZedVersion> {
None
}
}
impl VersionedMessage for proto::SaveBuffer {
fn required_host_version(&self) -> Option<ZedVersion> {
if self.new_path.is_some() {
Some(ZedVersion::with_save_as())
} else {
None
}
}
}
impl VersionedMessage for proto::OpenNewBuffer {
fn required_host_version(&self) -> Option<ZedVersion> {
Some(ZedVersion::with_save_as())
}
}
#[derive(Serialize)]
@ -50,6 +76,10 @@ impl ConnectionPool {
self.channels.clear();
}
pub fn connection(&mut self, connection_id: ConnectionId) -> Option<&Connection> {
self.connections.get(&connection_id)
}
#[instrument(skip(self))]
pub fn add_connection(
&mut self,