mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-09 00:50:04 +03:00
Get integration tests passing
* Fix misuse of guest buffer's id as its remote id Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
f1fc0bde99
commit
2712cadaf6
@ -427,7 +427,7 @@ impl Project {
|
||||
for worktree in this.worktrees(cx).collect::<Vec<_>>() {
|
||||
worktree.update(cx, |worktree, cx| {
|
||||
let worktree = worktree.as_local_mut().unwrap();
|
||||
tasks.push(worktree.share(cx));
|
||||
tasks.push(worktree.share(project_id, cx));
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -526,12 +526,14 @@ impl Project {
|
||||
|
||||
cx.spawn(move |this, mut cx| async move {
|
||||
let load_result = load_buffer.await;
|
||||
*tx.borrow_mut() = Some(this.update(&mut cx, |this, _| {
|
||||
*tx.borrow_mut() = Some(this.update(&mut cx, |this, cx| {
|
||||
// Record the fact that the buffer is no longer loading.
|
||||
this.loading_buffers.remove(&path);
|
||||
let buffer = load_result.map_err(Arc::new)?;
|
||||
this.open_buffers
|
||||
.insert(buffer.id(), OpenBuffer::Loaded(buffer.downgrade()));
|
||||
this.open_buffers.insert(
|
||||
buffer.read(cx).remote_id() as usize,
|
||||
OpenBuffer::Loaded(buffer.downgrade()),
|
||||
);
|
||||
Ok((buffer, Arc::new(AtomicBool::new(true))))
|
||||
}));
|
||||
})
|
||||
@ -1109,7 +1111,7 @@ impl Project {
|
||||
if is_shared {
|
||||
worktree
|
||||
.update(&mut cx, |worktree, cx| {
|
||||
worktree.as_local_mut().unwrap().share(cx)
|
||||
worktree.as_local_mut().unwrap().share(project_id, cx)
|
||||
})
|
||||
.await?;
|
||||
}
|
||||
|
@ -739,13 +739,11 @@ impl LocalWorktree {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn share(&mut self, cx: &mut ModelContext<Worktree>) -> Task<anyhow::Result<()>> {
|
||||
let project_id = if let Registration::Done { project_id } = self.registration {
|
||||
project_id
|
||||
} else {
|
||||
return Task::ready(Err(anyhow!("cannot share worktree before registering it")));
|
||||
};
|
||||
|
||||
pub fn share(
|
||||
&mut self,
|
||||
project_id: u64,
|
||||
cx: &mut ModelContext<Worktree>,
|
||||
) -> Task<anyhow::Result<()>> {
|
||||
if self.share.is_some() {
|
||||
return Task::ready(Ok(()));
|
||||
}
|
||||
|
@ -1160,10 +1160,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/a", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/a", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
let worktree_id = worktree_a.read_with(&cx_a, |tree, _| tree.id());
|
||||
@ -1298,10 +1296,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/a", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/a", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -1400,10 +1396,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/a", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/a", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -1470,7 +1464,9 @@ mod tests {
|
||||
.condition(&mut cx_a, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
|
||||
.await;
|
||||
buffer_b
|
||||
.condition(&mut cx_b, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
|
||||
.condition(&mut cx_b, |buf, _| {
|
||||
dbg!(buf.text()) == "i-am-c, i-am-b, i-am-a"
|
||||
})
|
||||
.await;
|
||||
buffer_c
|
||||
.condition(&mut cx_c, |buf, _| buf.text() == "i-am-c, i-am-b, i-am-a")
|
||||
@ -1550,10 +1546,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/dir", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/dir", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -1645,10 +1639,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/dir", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/dir", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -1725,10 +1717,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/dir", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/dir", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -1801,10 +1791,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/a", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/a", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -1890,10 +1878,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/a", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/a", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -2110,10 +2096,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/a", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/a", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
@ -2617,10 +2601,8 @@ mod tests {
|
||||
cx,
|
||||
)
|
||||
});
|
||||
let (worktree_a, _) = project_a
|
||||
.update(&mut cx_a, |p, cx| {
|
||||
p.find_or_create_worktree_for_abs_path("/a", false, cx)
|
||||
})
|
||||
let worktree_a = project_a
|
||||
.update(&mut cx_a, |p, cx| p.add_local_worktree("/a", false, cx))
|
||||
.await
|
||||
.unwrap();
|
||||
worktree_a
|
||||
|
Loading…
Reference in New Issue
Block a user