Send full multibuffer anchors to following peers

This commit is contained in:
Max Brunsfeld 2022-11-28 18:00:38 -08:00
parent 3eac3e20d5
commit 6d9b55a654
4 changed files with 73 additions and 74 deletions

View file

@ -2813,6 +2813,10 @@ impl MultiBufferSnapshot {
}
}
pub fn buffer_id_for_excerpt(&self, excerpt_id: ExcerptId) -> Option<usize> {
Some(self.excerpt(excerpt_id)?.buffer_id)
}
fn excerpt<'a>(&'a self, excerpt_id: ExcerptId) -> Option<&'a Excerpt> {
let mut cursor = self.excerpts.cursor::<Option<&Locator>>();
let locator = self.excerpt_locator_for_id(excerpt_id);
@ -3147,6 +3151,14 @@ impl ExcerptId {
Self(usize::MAX)
}
pub fn to_proto(&self) -> u64 {
self.0 as _
}
pub fn from_proto(proto: u64) -> Self {
Self(proto as _)
}
pub fn cmp(&self, other: &Self, snapshot: &MultiBufferSnapshot) -> cmp::Ordering {
let a = snapshot.excerpt_locator_for_id(*self);
let b = snapshot.excerpt_locator_for_id(*other);