Replicate pending selections separately from other selections
This fixes a panic that would occur when a leader created a pending selection that overlapped another selection, because the follower would attempt to treat that pending selection as non-pending, which would violate the invariant that selections are sorted and disjoint.
This commit is contained in:
parent
8c64514570
commit
1e02ebbd11
4 changed files with 37 additions and 12 deletions
|
@ -5453,11 +5453,17 @@ impl Editor {
|
|||
pub fn set_selections_from_remote(
|
||||
&mut self,
|
||||
selections: Vec<Selection<Anchor>>,
|
||||
pending_selection: Option<Selection<Anchor>>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
let old_cursor_position = self.selections.newest_anchor().head();
|
||||
self.selections.change_with(cx, |s| {
|
||||
s.select_anchors(selections);
|
||||
if let Some(pending_selection) = pending_selection {
|
||||
s.set_pending(pending_selection, SelectMode::Character);
|
||||
} else {
|
||||
s.clear_pending();
|
||||
}
|
||||
});
|
||||
self.selections_did_change(false, &old_cursor_position, cx);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue