@@ -15,9 +15,7 @@ use collections::HashMap;
use gpui::AsyncApp;
use gpui::Entity;
use language::{Anchor, Buffer, OffsetRangeExt as _, TextBufferSnapshot};
-use project::{Project, ProjectPath};
-use util::paths::PathStyle;
-use util::rel_path::RelPath;
+use project::Project;
#[derive(Clone, Debug)]
pub struct OpenedBuffers(#[allow(unused)] HashMap<String, Entity<Buffer>>);
@@ -30,27 +28,15 @@ pub async fn apply_diff(
) -> Result<OpenedBuffers> {
let mut included_files = HashMap::default();
- let worktree_id = project.read_with(cx, |project, cx| {
- anyhow::Ok(
- project
- .visible_worktrees(cx)
- .next()
- .context("no worktrees")?
- .read(cx)
- .id(),
- )
- })??;
-
for line in diff_str.lines() {
let diff_line = DiffLine::parse(line);
if let DiffLine::OldPath { path } = diff_line {
let buffer = project
.update(cx, |project, cx| {
- let project_path = ProjectPath {
- worktree_id,
- path: RelPath::new(Path::new(path.as_ref()), PathStyle::Posix)?.into_arc(),
- };
+ let project_path = project
+ .find_project_path(path.as_ref(), cx)
+ .context("no such path")?;
anyhow::Ok(project.open_buffer(project_path, cx))
})??
.await?;