Reflect leader's view state when recycling existing local editors

This commit is contained in:
Antonio Scandurra
2022-03-22 10:51:17 +01:00
parent 34e5a1f6bb
commit 5dc36260e5
2 changed files with 61 additions and 24 deletions
+19 -5
View File
@@ -1116,7 +1116,7 @@ mod tests {
},
time::Duration,
};
use workspace::{Settings, SplitDirection, Workspace, WorkspaceParams};
use workspace::{Item, Settings, SplitDirection, Workspace, WorkspaceParams};
#[cfg(test)]
#[ctor::ctor]
@@ -4287,7 +4287,9 @@ mod tests {
.downcast::<Editor>()
.unwrap();
// Client B starts following client A.
// When client B starts following client A, all visible view states are replicated to client B.
editor_a1.update(cx_a, |editor, cx| editor.select_ranges([0..1], None, cx));
editor_a2.update(cx_a, |editor, cx| editor.select_ranges([2..3], None, cx));
workspace_b
.update(cx_b, |workspace, cx| {
let leader_id = project_b
@@ -4301,13 +4303,25 @@ mod tests {
})
.await
.unwrap();
assert_eq!(
workspace_b.read_with(cx_b, |workspace, cx| workspace
let editor_b2 = workspace_b.read_with(cx_b, |workspace, cx| {
workspace
.active_item(cx)
.unwrap()
.project_path(cx)),
.downcast::<Editor>()
.unwrap()
});
assert_eq!(
editor_b2.read_with(cx_b, |editor, cx| editor.project_path(cx)),
Some((worktree_id, "2.txt").into())
);
assert_eq!(
editor_b2.read_with(cx_b, |editor, cx| editor.selected_ranges(cx)),
vec![2..3]
);
assert_eq!(
editor_b1.read_with(cx_b, |editor, cx| editor.selected_ranges(cx)),
vec![0..1]
);
// When client A activates a different editor, client B does so as well.
workspace_a.update(cx_a, |workspace, cx| {