Add integration test coverage for following into multibuffers
This commit is contained in:
parent
e4c5dfcf6c
commit
954c9ac3fd
1 changed files with 80 additions and 12 deletions
|
@ -13,8 +13,8 @@ use client::{
|
||||||
};
|
};
|
||||||
use collections::{BTreeMap, HashMap, HashSet};
|
use collections::{BTreeMap, HashMap, HashSet};
|
||||||
use editor::{
|
use editor::{
|
||||||
self, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, Redo, Rename, ToOffset,
|
self, ConfirmCodeAction, ConfirmCompletion, ConfirmRename, Editor, ExcerptRange, MultiBuffer,
|
||||||
ToggleCodeActions, Undo,
|
Redo, Rename, ToOffset, ToggleCodeActions, Undo,
|
||||||
};
|
};
|
||||||
use fs::{FakeFs, Fs as _, HomeDir, LineEnding};
|
use fs::{FakeFs, Fs as _, HomeDir, LineEnding};
|
||||||
use futures::{channel::oneshot, StreamExt as _};
|
use futures::{channel::oneshot, StreamExt as _};
|
||||||
|
@ -4813,9 +4813,9 @@ async fn test_following(
|
||||||
.insert_tree(
|
.insert_tree(
|
||||||
"/a",
|
"/a",
|
||||||
json!({
|
json!({
|
||||||
"1.txt": "one",
|
"1.txt": "one\none\none",
|
||||||
"2.txt": "two",
|
"2.txt": "two\ntwo\ntwo",
|
||||||
"3.txt": "three",
|
"3.txt": "three\nthree\nthree",
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
@ -4919,7 +4919,67 @@ async fn test_following(
|
||||||
assert_eq!(workspace.active_item(cx).unwrap().id(), editor_b1.id());
|
assert_eq!(workspace.active_item(cx).unwrap().id(), editor_b1.id());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// When client A opens a multibuffer, client B does so as well.
|
||||||
|
let multibuffer_a = cx_a.add_model(|cx| {
|
||||||
|
let buffer_a1 = project_a.update(cx, |project, cx| {
|
||||||
|
project
|
||||||
|
.get_open_buffer(&(worktree_id, "1.txt").into(), cx)
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
|
let buffer_a2 = project_a.update(cx, |project, cx| {
|
||||||
|
project
|
||||||
|
.get_open_buffer(&(worktree_id, "2.txt").into(), cx)
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
|
let mut result = MultiBuffer::new(0);
|
||||||
|
result.push_excerpts(
|
||||||
|
buffer_a1,
|
||||||
|
[ExcerptRange {
|
||||||
|
context: 0..3,
|
||||||
|
primary: None,
|
||||||
|
}],
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
result.push_excerpts(
|
||||||
|
buffer_a2,
|
||||||
|
[ExcerptRange {
|
||||||
|
context: 4..7,
|
||||||
|
primary: None,
|
||||||
|
}],
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
result
|
||||||
|
});
|
||||||
|
let multibuffer_editor_a = workspace_a.update(cx_a, |workspace, cx| {
|
||||||
|
let editor =
|
||||||
|
cx.add_view(|cx| Editor::for_multibuffer(multibuffer_a, Some(project_a.clone()), cx));
|
||||||
|
workspace.add_item(Box::new(editor.clone()), cx);
|
||||||
|
editor
|
||||||
|
});
|
||||||
|
deterministic.run_until_parked();
|
||||||
|
let multibuffer_editor_b = workspace_b.read_with(cx_b, |workspace, cx| {
|
||||||
|
workspace
|
||||||
|
.active_item(cx)
|
||||||
|
.unwrap()
|
||||||
|
.downcast::<Editor>()
|
||||||
|
.unwrap()
|
||||||
|
});
|
||||||
|
assert_eq!(
|
||||||
|
multibuffer_editor_a.read_with(cx_a, |editor, cx| editor.text(cx)),
|
||||||
|
multibuffer_editor_b.read_with(cx_b, |editor, cx| editor.text(cx)),
|
||||||
|
);
|
||||||
|
|
||||||
// When client A navigates back and forth, client B does so as well.
|
// When client A navigates back and forth, client B does so as well.
|
||||||
|
workspace_a
|
||||||
|
.update(cx_a, |workspace, cx| {
|
||||||
|
workspace::Pane::go_back(workspace, None, cx)
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
deterministic.run_until_parked();
|
||||||
|
workspace_b.read_with(cx_b, |workspace, cx| {
|
||||||
|
assert_eq!(workspace.active_item(cx).unwrap().id(), editor_b1.id());
|
||||||
|
});
|
||||||
|
|
||||||
workspace_a
|
workspace_a
|
||||||
.update(cx_a, |workspace, cx| {
|
.update(cx_a, |workspace, cx| {
|
||||||
workspace::Pane::go_back(workspace, None, cx)
|
workspace::Pane::go_back(workspace, None, cx)
|
||||||
|
@ -5029,13 +5089,21 @@ async fn test_following(
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
deterministic.run_until_parked();
|
deterministic.run_until_parked();
|
||||||
|
workspace_a.read_with(cx_a, |workspace, cx| {
|
||||||
|
assert_eq!(workspace.active_item(cx).unwrap().id(), editor_a1.id())
|
||||||
|
});
|
||||||
|
|
||||||
|
// Client B activates a multibuffer that was created by following client A. Client A returns to that multibuffer.
|
||||||
|
workspace_b.update(cx_b, |workspace, cx| {
|
||||||
|
workspace.activate_item(&multibuffer_editor_b, cx)
|
||||||
|
});
|
||||||
|
deterministic.run_until_parked();
|
||||||
|
workspace_a.read_with(cx_a, |workspace, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
workspace_a.read_with(cx_a, |workspace, cx| workspace
|
workspace.active_item(cx).unwrap().id(),
|
||||||
.active_item(cx)
|
multibuffer_editor_a.id()
|
||||||
.unwrap()
|
)
|
||||||
.id()),
|
});
|
||||||
editor_a1.id()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Client B activates an external window again, and the previously-opened screen-sharing item
|
// Client B activates an external window again, and the previously-opened screen-sharing item
|
||||||
// gets activated.
|
// gets activated.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue