diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 7c616762d8..86b0b0b92b 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -70,6 +70,7 @@ pub struct Buffer { diagnostics_timestamp: clock::Lamport, file_update_count: usize, completion_triggers: Vec, + completion_triggers_timestamp: clock::Lamport, deferred_ops: OperationQueue, } @@ -375,34 +376,6 @@ impl Buffer { .collect::>>()?; this.apply_ops(ops, cx)?; - for selection_set in message.selections { - let lamport_timestamp = clock::Lamport { - replica_id: selection_set.replica_id as ReplicaId, - value: selection_set.lamport_timestamp, - }; - this.remote_selections.insert( - selection_set.replica_id as ReplicaId, - SelectionSet { - line_mode: selection_set.line_mode, - selections: proto::deserialize_selections(selection_set.selections), - lamport_timestamp, - }, - ); - this.text.lamport_clock.observe(lamport_timestamp); - } - let snapshot = this.snapshot(); - let entries = proto::deserialize_diagnostics(message.diagnostics); - this.apply_diagnostic_update( - DiagnosticSet::from_sorted_entries(entries.iter().cloned(), &snapshot), - clock::Lamport { - replica_id: 0, - value: message.diagnostics_timestamp, - }, - cx, - ); - - this.completion_triggers = message.completion_triggers; - Ok(this) } @@ -412,6 +385,25 @@ impl Buffer { .history() .map(|op| proto::serialize_operation(&Operation::Buffer(op.clone()))) .chain(self.deferred_ops.iter().map(proto::serialize_operation)) + .chain(self.remote_selections.iter().map(|(_, set)| { + proto::serialize_operation(&Operation::UpdateSelections { + selections: set.selections.clone(), + lamport_timestamp: set.lamport_timestamp, + line_mode: set.line_mode, + }) + })) + .chain(Some(proto::serialize_operation( + &Operation::UpdateDiagnostics { + diagnostics: self.diagnostics.iter().cloned().collect(), + lamport_timestamp: self.diagnostics_timestamp, + }, + ))) + .chain(Some(proto::serialize_operation( + &Operation::UpdateCompletionTriggers { + triggers: self.completion_triggers.clone(), + lamport_timestamp: self.completion_triggers_timestamp, + }, + ))) .collect::>(); operations.sort_unstable_by_key(proto::lamport_timestamp_for_operation); proto::Buffer { @@ -419,19 +411,6 @@ impl Buffer { file: self.file.as_ref().map(|f| f.to_proto()), base_text: self.base_text().to_string(), operations, - selections: self - .remote_selections - .iter() - .map(|(replica_id, set)| proto::SelectionSet { - replica_id: *replica_id as u32, - selections: proto::serialize_selections(&set.selections), - lamport_timestamp: set.lamport_timestamp.value, - line_mode: set.line_mode, - }) - .collect(), - diagnostics: proto::serialize_diagnostics(self.diagnostics.iter()), - diagnostics_timestamp: self.diagnostics_timestamp.value, - completion_triggers: self.completion_triggers.clone(), line_ending: proto::serialize_line_ending(self.line_ending()) as i32, } } @@ -470,6 +449,7 @@ impl Buffer { diagnostics_timestamp: Default::default(), file_update_count: 0, completion_triggers: Default::default(), + completion_triggers_timestamp: Default::default(), deferred_ops: OperationQueue::new(), } } @@ -1517,11 +1497,11 @@ impl Buffer { pub fn set_completion_triggers(&mut self, triggers: Vec, cx: &mut ModelContext) { self.completion_triggers = triggers.clone(); - let lamport_timestamp = self.text.lamport_clock.tick(); + self.completion_triggers_timestamp = self.text.lamport_clock.tick(); self.send_operation( Operation::UpdateCompletionTriggers { triggers, - lamport_timestamp, + lamport_timestamp: self.completion_triggers_timestamp, }, cx, ); diff --git a/crates/rpc/proto/zed.proto b/crates/rpc/proto/zed.proto index c803ff85b5..0da6d4d360 100644 --- a/crates/rpc/proto/zed.proto +++ b/crates/rpc/proto/zed.proto @@ -813,11 +813,7 @@ message Buffer { optional File file = 2; string base_text = 3; repeated Operation operations = 4; - repeated SelectionSet selections = 5; - repeated Diagnostic diagnostics = 6; - uint32 diagnostics_timestamp = 7; - repeated string completion_triggers = 8; - LineEnding line_ending = 9; + LineEnding line_ending = 5; } enum LineEnding { diff --git a/crates/rpc/src/rpc.rs b/crates/rpc/src/rpc.rs index b3c7aa0046..308e5b0f43 100644 --- a/crates/rpc/src/rpc.rs +++ b/crates/rpc/src/rpc.rs @@ -6,4 +6,4 @@ pub use conn::Connection; pub use peer::*; mod macros; -pub const PROTOCOL_VERSION: u32 = 30; +pub const PROTOCOL_VERSION: u32 = 31;