Show cursors for remote participants
This commit is contained in:
parent
26a3f68080
commit
0ca9f286c6
6 changed files with 122 additions and 4 deletions
|
@ -627,6 +627,7 @@ pub struct RemoteSelection {
|
|||
pub peer_id: PeerId,
|
||||
pub line_mode: bool,
|
||||
pub participant_index: Option<ParticipantIndex>,
|
||||
pub user_name: Option<SharedString>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -9246,6 +9247,7 @@ pub trait CollaborationHub {
|
|||
&self,
|
||||
cx: &'a AppContext,
|
||||
) -> &'a HashMap<u64, ParticipantIndex>;
|
||||
fn user_names(&self, cx: &AppContext) -> HashMap<u64, SharedString>;
|
||||
}
|
||||
|
||||
impl CollaborationHub for Model<Project> {
|
||||
|
@ -9259,6 +9261,14 @@ impl CollaborationHub for Model<Project> {
|
|||
) -> &'a HashMap<u64, ParticipantIndex> {
|
||||
self.read(cx).user_store().read(cx).participant_indices()
|
||||
}
|
||||
|
||||
fn user_names(&self, cx: &AppContext) -> HashMap<u64, SharedString> {
|
||||
let this = self.read(cx);
|
||||
let user_ids = this.collaborators().values().map(|c| c.user_id);
|
||||
this.user_store().read_with(cx, |user_store, cx| {
|
||||
user_store.participant_names(user_ids, cx)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn inlay_hint_settings(
|
||||
|
@ -9310,6 +9320,7 @@ impl EditorSnapshot {
|
|||
collaboration_hub: &dyn CollaborationHub,
|
||||
cx: &'a AppContext,
|
||||
) -> impl 'a + Iterator<Item = RemoteSelection> {
|
||||
let participant_names = collaboration_hub.user_names(cx);
|
||||
let participant_indices = collaboration_hub.user_participant_indices(cx);
|
||||
let collaborators_by_peer_id = collaboration_hub.collaborators(cx);
|
||||
let collaborators_by_replica_id = collaborators_by_peer_id
|
||||
|
@ -9321,6 +9332,7 @@ impl EditorSnapshot {
|
|||
.filter_map(move |(replica_id, line_mode, cursor_shape, selection)| {
|
||||
let collaborator = collaborators_by_replica_id.get(&replica_id)?;
|
||||
let participant_index = participant_indices.get(&collaborator.user_id).copied();
|
||||
let user_name = participant_names.get(&collaborator.user_id).cloned();
|
||||
Some(RemoteSelection {
|
||||
replica_id,
|
||||
selection,
|
||||
|
@ -9328,6 +9340,7 @@ impl EditorSnapshot {
|
|||
line_mode,
|
||||
participant_index,
|
||||
peer_id: collaborator.peer_id,
|
||||
user_name,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue