ep cli: Create entries from new files in edit history (#46196)

Release Notes:

- N/A
This commit is contained in:
Agus Zubiaga authored and GitHub committed 2026-01-06 18:56:55 -03:00
1 parent f324b2d004
commit 35da6e003f
1 file changed
+28 -7
+28 -7
View File
@@ -12,7 +12,7 @@ use collections::HashMap;
use gpui::{AsyncApp, Entity};
use language::{Anchor, Buffer, OffsetRangeExt as _, TextBufferSnapshot, text_diff};
use postage::stream::Stream as _;
use project::Project;
use project::{Project, ProjectPath};
use util::{paths::PathStyle, rel_path::RelPath};
use worktree::Worktree;
@@ -56,14 +56,35 @@ pub async fn apply_diff(
hunk,
is_new_file,
} => {
let project_path = project
.update(cx, |project, cx| {
project.find_project_path(path.as_ref(), cx)
})?
.context("no such path")?;
let buffer = match current_file {
None => {
if is_new_file {
let rel_path = RelPath::new(Path::new(path.as_ref()), PathStyle::Posix)
.unwrap()
.into_arc();
project
.update(cx, |project, cx| {
project.create_entry(
ProjectPath {
worktree_id: worktree.read(cx).id(),
path: rel_path,
},
false,
cx,
)
})?
.await?;
}
let project_path = project
.update(cx, |project, cx| {
project.find_project_path(path.as_ref(), cx)
})?
.with_context(|| {
format!("Failed to find project path in diff: {}", path)
})?;
let buffer = project
.update(cx, |project, cx| project.open_buffer(project_path, cx))?
.await?;