From 7bdef097659977bedcd2fae6b956f9fa04e14e20 Mon Sep 17 00:00:00 2001 From: adz Date: Sun, 23 Aug 2026 17:51:20 +0200 Subject: [PATCH] doc: Remove cursor when author left Co-authored-by: niklaswimmer --- reflection-doc/src/document.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/reflection-doc/src/document.rs b/reflection-doc/src/document.rs index b0f776a4..d21ecd2d 100644 --- a/reflection-doc/src/document.rs +++ b/reflection-doc/src/document.rs @@ -535,7 +535,8 @@ mod imp { obj, #[upgrade_or_default] move |stack_type, _, _| { - // The `loro::UndoManager` holds internal locks, so we can't update the `Document.can_undo/can_redo` property inline + // The `loro::UndoManager` holds internal locks, so we can't update the + // `Document.can_undo/can_redo` property inline obj.main_context().spawn(clone!( #[weak] obj, @@ -661,6 +662,12 @@ mod imp { } } + pub(super) fn handle_author_left(&self, author: Author) { + // Negative insert cursor position will delete marker in the text-view. + self.obj() + .emit_by_name::<()>("remote-insert-cursor", &[&author, &-1i32, &-1i32]); + } + pub(super) fn subscription(&self) -> Option>> { self.subscription.read().unwrap().clone() } @@ -941,6 +948,8 @@ impl TopicSubscription for DocumentHandle { document.main_context().invoke(move || { let author = document.authors().add(VerifyingKey(author)); author.set_online(false); + + document.imp().handle_author_left(author); }); } }