Change integration tests to open buffers via the project
This commit is contained in:
parent
a578d71ea2
commit
6751bd9d78
3 changed files with 88 additions and 100 deletions
|
@ -476,9 +476,10 @@ impl Project {
|
|||
|
||||
pub fn open_buffer(
|
||||
&mut self,
|
||||
path: ProjectPath,
|
||||
path: impl Into<ProjectPath>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Task<Result<ModelHandle<Buffer>>> {
|
||||
let path = path.into();
|
||||
let worktree = if let Some(worktree) = self.worktree_for_id(path.worktree_id, cx) {
|
||||
worktree
|
||||
} else {
|
||||
|
@ -520,6 +521,13 @@ impl Project {
|
|||
})
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn has_open_buffer(&self, path: impl Into<ProjectPath>, cx: &AppContext) -> bool {
|
||||
let path = path.into();
|
||||
self.worktree_for_id(path.worktree_id, cx)
|
||||
.map_or(false, |tree| tree.read(cx).has_open_buffer(path.path, cx))
|
||||
}
|
||||
|
||||
fn assign_language_to_buffer(
|
||||
&mut self,
|
||||
worktree: ModelHandle<Worktree>,
|
||||
|
@ -1470,6 +1478,15 @@ impl Collaborator {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: AsRef<Path>> From<(WorktreeId, P)> for ProjectPath {
|
||||
fn from((worktree_id, path): (WorktreeId, P)) -> Self {
|
||||
Self {
|
||||
worktree_id,
|
||||
path: path.as_ref().into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Event, *};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue