Skip to content

Commit 0408478

Browse files
committed
doc: Remove cursor when author left
1 parent 09d5000 commit 0408478

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

reflection-doc/src/document.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,8 @@ mod imp {
535535
obj,
536536
#[upgrade_or_default]
537537
move |stack_type, _, _| {
538-
// The `loro::UndoManager` holds internal locks, so we can't update the `Document.can_undo/can_redo` property inline
538+
// The `loro::UndoManager` holds internal locks, so we can't update the
539+
// `Document.can_undo/can_redo` property inline
539540
obj.main_context().spawn(clone!(
540541
#[weak]
541542
obj,
@@ -661,6 +662,12 @@ mod imp {
661662
}
662663
}
663664

665+
pub(super) fn handle_author_left(&self, author: Author) {
666+
// Negative insert cursor position will delete marker in the text-view.
667+
self.obj()
668+
.emit_by_name::<()>("remote-insert-cursor", &[&author, &-1i32, &-1i32]);
669+
}
670+
664671
pub(super) fn subscription(&self) -> Option<Arc<TopicStream<DocumentHandle>>> {
665672
self.subscription.read().unwrap().clone()
666673
}
@@ -941,6 +948,8 @@ impl TopicSubscription for DocumentHandle {
941948
document.main_context().invoke(move || {
942949
let author = document.authors().add(VerifyingKey(author));
943950
author.set_online(false);
951+
952+
document.imp().handle_author_left(author);
944953
});
945954
}
946955
}

0 commit comments

Comments
 (0)