Avoid sending unnecessary messages for local projects that aren't shared
This commit is contained in:
parent
9fa03b2f28
commit
b9dc476e74
1 changed files with 28 additions and 10 deletions
|
@ -675,6 +675,23 @@ impl Project {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn shared_remote_id(&self) -> Option<u64> {
|
||||||
|
match &self.client_state {
|
||||||
|
ProjectClientState::Local {
|
||||||
|
remote_id_rx,
|
||||||
|
is_shared,
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if *is_shared {
|
||||||
|
*remote_id_rx.borrow()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ProjectClientState::Remote { remote_id, .. } => Some(*remote_id),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn replica_id(&self) -> ReplicaId {
|
pub fn replica_id(&self) -> ReplicaId {
|
||||||
match &self.client_state {
|
match &self.client_state {
|
||||||
ProjectClientState::Local { .. } => 0,
|
ProjectClientState::Local { .. } => 0,
|
||||||
|
@ -1468,13 +1485,14 @@ impl Project {
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
match event {
|
match event {
|
||||||
BufferEvent::Operation(operation) => {
|
BufferEvent::Operation(operation) => {
|
||||||
let project_id = self.remote_id()?;
|
if let Some(project_id) = self.shared_remote_id() {
|
||||||
let request = self.client.request(proto::UpdateBuffer {
|
let request = self.client.request(proto::UpdateBuffer {
|
||||||
project_id,
|
project_id,
|
||||||
buffer_id: buffer.read(cx).remote_id(),
|
buffer_id: buffer.read(cx).remote_id(),
|
||||||
operations: vec![language::proto::serialize_operation(&operation)],
|
operations: vec![language::proto::serialize_operation(&operation)],
|
||||||
});
|
});
|
||||||
cx.background().spawn(request).detach_and_log_err(cx);
|
cx.background().spawn(request).detach_and_log_err(cx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BufferEvent::Edited { .. } => {
|
BufferEvent::Edited { .. } => {
|
||||||
let (_, language_server) = self
|
let (_, language_server) = self
|
||||||
|
@ -1718,7 +1736,7 @@ impl Project {
|
||||||
)
|
)
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
if let Some(project_id) = this.remote_id() {
|
if let Some(project_id) = this.shared_remote_id() {
|
||||||
this.client
|
this.client
|
||||||
.send(proto::StartLanguageServer {
|
.send(proto::StartLanguageServer {
|
||||||
project_id,
|
project_id,
|
||||||
|
@ -2063,7 +2081,7 @@ impl Project {
|
||||||
language_server_id: usize,
|
language_server_id: usize,
|
||||||
event: proto::update_language_server::Variant,
|
event: proto::update_language_server::Variant,
|
||||||
) {
|
) {
|
||||||
if let Some(project_id) = self.remote_id() {
|
if let Some(project_id) = self.shared_remote_id() {
|
||||||
self.client
|
self.client
|
||||||
.send(proto::UpdateLanguageServer {
|
.send(proto::UpdateLanguageServer {
|
||||||
project_id,
|
project_id,
|
||||||
|
@ -3746,7 +3764,7 @@ impl Project {
|
||||||
renamed_buffers.push((cx.handle(), old_path));
|
renamed_buffers.push((cx.handle(), old_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(project_id) = self.remote_id() {
|
if let Some(project_id) = self.shared_remote_id() {
|
||||||
self.client
|
self.client
|
||||||
.send(proto::UpdateBufferFile {
|
.send(proto::UpdateBufferFile {
|
||||||
project_id,
|
project_id,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue