mirror of
https://github.com/zed-industries/zed.git
synced 2024-09-20 10:57:22 +03:00
In editor following test, apply excerpt removals to both followers
This commit is contained in:
parent
11800a8a78
commit
09d3fbf04f
@ -5129,9 +5129,9 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let follower_1_update = Rc::new(RefCell::new(None));
|
let update_message = Rc::new(RefCell::new(None));
|
||||||
follower_1.update(cx, {
|
follower_1.update(cx, {
|
||||||
let update = follower_1_update.clone();
|
let update = update_message.clone();
|
||||||
|_, cx| {
|
|_, cx| {
|
||||||
cx.subscribe(&leader, move |_, leader, event, cx| {
|
cx.subscribe(&leader, move |_, leader, event, cx| {
|
||||||
leader
|
leader
|
||||||
@ -5192,6 +5192,19 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Apply the update of adding the excerpts.
|
||||||
|
follower_1
|
||||||
|
.update(cx, |follower, cx| {
|
||||||
|
follower.apply_update_proto(&project, update_message.borrow().clone().unwrap(), cx)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
follower_1.read_with(cx, Editor::text),
|
||||||
|
leader.read_with(cx, Editor::text)
|
||||||
|
);
|
||||||
|
update_message.borrow_mut().take();
|
||||||
|
|
||||||
// Start following separately after it already has excerpts.
|
// Start following separately after it already has excerpts.
|
||||||
let mut state_message = leader.update(cx, |leader, cx| leader.to_state_proto(cx));
|
let mut state_message = leader.update(cx, |leader, cx| leader.to_state_proto(cx));
|
||||||
let follower_2 = cx
|
let follower_2 = cx
|
||||||
@ -5206,22 +5219,6 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||||||
leader.read_with(cx, Editor::text)
|
leader.read_with(cx, Editor::text)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Apply the update of adding the excerpts.
|
|
||||||
follower_1
|
|
||||||
.update(cx, |follower, cx| {
|
|
||||||
follower.apply_update_proto(
|
|
||||||
&project,
|
|
||||||
follower_1_update.borrow_mut().take().unwrap(),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
follower_1.read_with(cx, Editor::text),
|
|
||||||
leader.read_with(cx, Editor::text)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Remove some excerpts.
|
// Remove some excerpts.
|
||||||
leader.update(cx, |leader, cx| {
|
leader.update(cx, |leader, cx| {
|
||||||
leader.buffer.update(cx, |multibuffer, cx| {
|
leader.buffer.update(cx, |multibuffer, cx| {
|
||||||
@ -5234,14 +5231,17 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) {
|
|||||||
// Apply the update of removing the excerpts.
|
// Apply the update of removing the excerpts.
|
||||||
follower_1
|
follower_1
|
||||||
.update(cx, |follower, cx| {
|
.update(cx, |follower, cx| {
|
||||||
follower.apply_update_proto(
|
follower.apply_update_proto(&project, update_message.borrow().clone().unwrap(), cx)
|
||||||
&project,
|
|
||||||
follower_1_update.borrow_mut().take().unwrap(),
|
|
||||||
cx,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
follower_2
|
||||||
|
.update(cx, |follower, cx| {
|
||||||
|
follower.apply_update_proto(&project, update_message.borrow().clone().unwrap(), cx)
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
update_message.borrow_mut().take();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
follower_1.read_with(cx, Editor::text),
|
follower_1.read_with(cx, Editor::text),
|
||||||
leader.read_with(cx, Editor::text)
|
leader.read_with(cx, Editor::text)
|
||||||
|
Loading…
Reference in New Issue
Block a user