mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Fix logic error when streaming ignored entries
We were calling `next` twice, which led us to skip every other entry. This commit also enhances the `test_share_project` integration test to exercise this new streaming logic.
This commit is contained in:
parent
94e70bc1a6
commit
85f228dade
2 changed files with 32 additions and 14 deletions
|
@ -1696,8 +1696,13 @@ mod tests {
|
|||
fs.insert_tree(
|
||||
"/a",
|
||||
json!({
|
||||
".gitignore": "ignored-dir",
|
||||
"a.txt": "a-contents",
|
||||
"b.txt": "b-contents",
|
||||
"ignored-dir": {
|
||||
"c.txt": "",
|
||||
"d.txt": "",
|
||||
}
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
|
@ -1727,7 +1732,6 @@ mod tests {
|
|||
// Join that project as client B
|
||||
let client_b_peer_id = client_b.peer_id;
|
||||
let project_b = client_b.build_remote_project(&project_a, cx_a, cx_b).await;
|
||||
|
||||
let replica_id_b = project_b.read_with(cx_b, |project, _| {
|
||||
assert_eq!(
|
||||
project
|
||||
|
@ -1740,16 +1744,27 @@ mod tests {
|
|||
);
|
||||
project.replica_id()
|
||||
});
|
||||
project_a
|
||||
.condition(&cx_a, |tree, _| {
|
||||
tree.collaborators()
|
||||
.get(&client_b_peer_id)
|
||||
.map_or(false, |collaborator| {
|
||||
collaborator.replica_id == replica_id_b
|
||||
&& collaborator.user.github_login == "user_b"
|
||||
})
|
||||
})
|
||||
.await;
|
||||
|
||||
deterministic.run_until_parked();
|
||||
project_a.read_with(cx_a, |project, _| {
|
||||
let client_b_collaborator = project.collaborators().get(&client_b_peer_id).unwrap();
|
||||
assert_eq!(client_b_collaborator.replica_id, replica_id_b);
|
||||
assert_eq!(client_b_collaborator.user.github_login, "user_b");
|
||||
});
|
||||
project_b.read_with(cx_b, |project, cx| {
|
||||
let worktree = project.worktrees(cx).next().unwrap().read(cx);
|
||||
assert_eq!(
|
||||
worktree.paths().map(AsRef::as_ref).collect::<Vec<_>>(),
|
||||
[
|
||||
Path::new(".gitignore"),
|
||||
Path::new("a.txt"),
|
||||
Path::new("b.txt"),
|
||||
Path::new("ignored-dir"),
|
||||
Path::new("ignored-dir/c.txt"),
|
||||
Path::new("ignored-dir/d.txt"),
|
||||
]
|
||||
);
|
||||
});
|
||||
|
||||
// Open the same file as client B and client A.
|
||||
let buffer_b = project_b
|
||||
|
|
|
@ -963,7 +963,11 @@ impl LocalWorktree {
|
|||
.filter(|e| e.is_ignored);
|
||||
let mut ignored_entries_to_send = Vec::new();
|
||||
loop {
|
||||
const CHUNK_SIZE: usize = 256;
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
const CHUNK_SIZE: usize = 2;
|
||||
#[cfg(not(any(test, feature = "test-support")))]
|
||||
const CHUNK_SIZE: usize = 128;
|
||||
|
||||
let entry = ignored_entries.next();
|
||||
if ignored_entries_to_send.len() >= CHUNK_SIZE || entry.is_none() {
|
||||
rpc.request(proto::UpdateWorktree {
|
||||
|
@ -977,7 +981,7 @@ impl LocalWorktree {
|
|||
.await?;
|
||||
}
|
||||
|
||||
if let Some(entry) = ignored_entries.next() {
|
||||
if let Some(entry) = entry {
|
||||
ignored_entries_to_send.push(entry.into());
|
||||
} else {
|
||||
break;
|
||||
|
@ -1179,7 +1183,6 @@ impl Snapshot {
|
|||
|
||||
for entry in update.updated_entries {
|
||||
let entry = Entry::try_from((&self.root_char_bag, entry))?;
|
||||
println!("{:?} = {}", &entry.path, entry.is_ignored);
|
||||
if let Some(PathEntry { path, .. }) = self.entries_by_id.get(&entry.id, &()) {
|
||||
entries_by_path_edits.push(Edit::Remove(PathKey(path.clone())));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue