Change integration tests to open buffers via the project

This commit is contained in:
Max Brunsfeld 2022-01-21 12:23:17 -08:00
parent a578d71ea2
commit 6751bd9d78
3 changed files with 88 additions and 100 deletions

View file

@ -322,14 +322,14 @@ impl Worktree {
.map(|(path, summary)| (path.0.clone(), summary.clone()))
}
pub fn loading_buffers<'a>(&'a mut self) -> &'a mut LoadingBuffers {
pub(crate) fn loading_buffers<'a>(&'a mut self) -> &'a mut LoadingBuffers {
match self {
Worktree::Local(worktree) => &mut worktree.loading_buffers,
Worktree::Remote(worktree) => &mut worktree.loading_buffers,
}
}
pub fn open_buffer(
pub(crate) fn open_buffer(
&mut self,
path: impl AsRef<Path>,
cx: &mut ModelContext<Self>,
@ -391,7 +391,7 @@ impl Worktree {
}
#[cfg(feature = "test-support")]
pub fn has_open_buffer(&self, path: impl AsRef<Path>, cx: &AppContext) -> bool {
pub(crate) fn has_open_buffer(&self, path: impl AsRef<Path>, cx: &AppContext) -> bool {
let mut open_buffers: Box<dyn Iterator<Item = _>> = match self {
Worktree::Local(worktree) => Box::new(worktree.open_buffers.values()),
Worktree::Remote(worktree) => {
@ -1577,16 +1577,6 @@ impl RemoteWorktree {
})
}
pub fn close_all_buffers(&mut self, cx: &mut MutableAppContext) {
for (_, buffer) in self.open_buffers.drain() {
if let RemoteBuffer::Loaded(buffer) = buffer {
if let Some(buffer) = buffer.upgrade(cx) {
buffer.update(cx, |buffer, cx| buffer.close(cx))
}
}
}
}
fn snapshot(&self) -> Snapshot {
self.snapshot.clone()
}