Match the leader's last selection when unfollowing
Co-Authored-By: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
3e0bc979c3
commit
06cd9ac664
5 changed files with 81 additions and 29 deletions
|
@ -1083,8 +1083,8 @@ mod tests {
|
|||
};
|
||||
use collections::BTreeMap;
|
||||
use editor::{
|
||||
self, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Input, Redo, Rename,
|
||||
ToOffset, ToggleCodeActions, Undo,
|
||||
self, Anchor, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Input, Redo,
|
||||
Rename, ToOffset, ToggleCodeActions, Undo,
|
||||
};
|
||||
use gpui::{executor, ModelHandle, TestAppContext, ViewHandle};
|
||||
use language::{
|
||||
|
@ -4290,7 +4290,13 @@ mod tests {
|
|||
// Client B starts following client A.
|
||||
workspace_b
|
||||
.update(cx_b, |workspace, cx| {
|
||||
let leader_id = *project_b.read(cx).collaborators().keys().next().unwrap();
|
||||
let leader_id = project_b
|
||||
.read(cx)
|
||||
.collaborators()
|
||||
.values()
|
||||
.next()
|
||||
.unwrap()
|
||||
.peer_id;
|
||||
workspace.toggle_follow(&leader_id.into(), cx).unwrap()
|
||||
})
|
||||
.await
|
||||
|
@ -4318,16 +4324,35 @@ mod tests {
|
|||
})
|
||||
.await;
|
||||
|
||||
editor_a1.update(cx_a, |editor, cx| {
|
||||
editor.select_ranges([2..2], None, cx);
|
||||
});
|
||||
editor_b1
|
||||
.condition(cx_b, |editor, cx| {
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let selection = snapshot
|
||||
.remote_selections_in_range(&(Anchor::min()..Anchor::max()))
|
||||
.next();
|
||||
selection.map_or(false, |selection| {
|
||||
selection.1.start.to_offset(&snapshot) == 2
|
||||
})
|
||||
})
|
||||
.await;
|
||||
|
||||
// After unfollowing, client B stops receiving updates from client A.
|
||||
workspace_b.update(cx_b, |workspace, cx| {
|
||||
workspace.unfollow(&workspace.active_pane().clone(), cx)
|
||||
});
|
||||
editor_b1.update(cx_b, |editor, cx| {
|
||||
assert_eq!(editor.selected_ranges::<usize>(cx), &[2..2]);
|
||||
});
|
||||
|
||||
workspace_a.update(cx_a, |workspace, cx| {
|
||||
workspace.activate_item(&editor_a2, cx);
|
||||
editor_a2.update(cx, |editor, cx| editor.set_text("ONE", cx));
|
||||
editor_a2.update(cx, |editor, cx| editor.set_text("TWO", cx));
|
||||
});
|
||||
editor_b2
|
||||
.condition(cx_b, |editor, cx| editor.text(cx) == "ONE")
|
||||
.condition(cx_b, |editor, cx| editor.text(cx) == "TWO")
|
||||
.await;
|
||||
assert_eq!(
|
||||
workspace_b.read_with(cx_b, |workspace, cx| workspace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue