mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-07 02:57:34 +00:00
Ensure leader updates don't change the active pane of followers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
9885c4f6ba
commit
c78bcf7116
1 changed files with 29 additions and 5 deletions
|
@ -4454,7 +4454,7 @@ mod tests {
|
||||||
|
|
||||||
// Client B opens an editor.
|
// Client B opens an editor.
|
||||||
let workspace_b = client_b.build_workspace(&project_b, cx_b);
|
let workspace_b = client_b.build_workspace(&project_b, cx_b);
|
||||||
let pane_b1 = workspace_a.read_with(cx_a, |workspace, _| workspace.active_pane().clone());
|
let pane_b1 = workspace_b.read_with(cx_b, |workspace, _| workspace.active_pane().clone());
|
||||||
let _editor_b1 = workspace_b
|
let _editor_b1 = workspace_b
|
||||||
.update(cx_b, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
workspace.open_path((worktree_id, "2.txt"), cx)
|
workspace.open_path((worktree_id, "2.txt"), cx)
|
||||||
|
@ -4491,13 +4491,15 @@ mod tests {
|
||||||
workspace_a
|
workspace_a
|
||||||
.update(cx_a, |workspace, cx| {
|
.update(cx_a, |workspace, cx| {
|
||||||
workspace.activate_next_pane(cx);
|
workspace.activate_next_pane(cx);
|
||||||
|
assert_eq!(*workspace.active_pane(), pane_a1);
|
||||||
workspace.open_path((worktree_id, "3.txt"), cx)
|
workspace.open_path((worktree_id, "3.txt"), cx)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
workspace_b
|
workspace_b
|
||||||
.update(cx_a, |workspace, cx| {
|
.update(cx_b, |workspace, cx| {
|
||||||
workspace.activate_next_pane(cx);
|
workspace.activate_next_pane(cx);
|
||||||
|
assert_eq!(*workspace.active_pane(), pane_b1);
|
||||||
workspace.open_path((worktree_id, "4.txt"), cx)
|
workspace.open_path((worktree_id, "4.txt"), cx)
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
|
@ -4506,20 +4508,42 @@ mod tests {
|
||||||
|
|
||||||
// Ensure leader updates don't change the active pane of followers
|
// Ensure leader updates don't change the active pane of followers
|
||||||
workspace_a.read_with(cx_a, |workspace, _| {
|
workspace_a.read_with(cx_a, |workspace, _| {
|
||||||
assert_ne!(*workspace.active_pane(), pane_a1);
|
assert_eq!(*workspace.active_pane(), pane_a1);
|
||||||
});
|
});
|
||||||
workspace_b.read_with(cx_b, |workspace, _| {
|
workspace_b.read_with(cx_b, |workspace, _| {
|
||||||
assert_ne!(*workspace.active_pane(), pane_b1);
|
assert_eq!(*workspace.active_pane(), pane_b1);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Ensure peers following each other doesn't cause an infinite loop.
|
// Ensure peers following each other doesn't cause an infinite loop.
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
workspace_b.read_with(cx_b, |workspace, cx| workspace
|
workspace_a.read_with(cx_a, |workspace, cx| workspace
|
||||||
.active_item(cx)
|
.active_item(cx)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.project_path(cx)),
|
.project_path(cx)),
|
||||||
Some((worktree_id, "3.txt").into())
|
Some((worktree_id, "3.txt").into())
|
||||||
);
|
);
|
||||||
|
workspace_a.update(cx_a, |workspace, cx| {
|
||||||
|
assert_eq!(
|
||||||
|
workspace.active_item(cx).unwrap().project_path(cx),
|
||||||
|
Some((worktree_id, "3.txt").into())
|
||||||
|
);
|
||||||
|
workspace.activate_next_pane(cx);
|
||||||
|
assert_eq!(
|
||||||
|
workspace.active_item(cx).unwrap().project_path(cx),
|
||||||
|
Some((worktree_id, "4.txt").into())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
workspace_b.update(cx_b, |workspace, cx| {
|
||||||
|
assert_eq!(
|
||||||
|
workspace.active_item(cx).unwrap().project_path(cx),
|
||||||
|
Some((worktree_id, "4.txt").into())
|
||||||
|
);
|
||||||
|
workspace.activate_next_pane(cx);
|
||||||
|
assert_eq!(
|
||||||
|
workspace.active_item(cx).unwrap().project_path(cx),
|
||||||
|
Some((worktree_id, "3.txt").into())
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(iterations = 10)]
|
#[gpui::test(iterations = 10)]
|
||||||
|
|
Loading…
Reference in a new issue