Assign unique color indices to room participants, use those instead of replica_ids

Co-authored-by: Conrad <conrad@zed.dev>
Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
Max Brunsfeld
2023-09-28 11:06:09 -07:00
co-authored by Conrad Antonio
parent 7711530704
commit 545b5e0161
35 changed files with 707 additions and 639 deletions
+8 -6
View File
@@ -1064,14 +1064,16 @@ impl<'de, T: DeserializeOwned> Deserialize<'de> for Interactive<T> {
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ColorIndex(pub u32);
impl Editor {
pub fn replica_selection_style(&self, replica_id: u16) -> &SelectionStyle {
let style_ix = replica_id as usize % (self.guest_selections.len() + 1);
if style_ix == 0 {
&self.selection
} else {
&self.guest_selections[style_ix - 1]
pub fn replica_selection_style(&self, color_index: ColorIndex) -> SelectionStyle {
if self.guest_selections.is_empty() {
return SelectionStyle::default();
}
let style_ix = color_index.0 as usize % self.guest_selections.len();
self.guest_selections[style_ix]
}
}