From 35da6e003f92379b2d448d9bba77e51a29ef2aaf Mon Sep 17 00:00:00 2001 From: Agus Zubiaga Date: Tue, 6 Jan 2026 18:56:55 -0300 Subject: [PATCH] ep cli: Create entries from new files in edit history (#46196) Release Notes: - N/A --- crates/edit_prediction/src/udiff.rs | 35 +++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/crates/edit_prediction/src/udiff.rs b/crates/edit_prediction/src/udiff.rs index c11eecaaae..d8967828ae 100644 --- a/crates/edit_prediction/src/udiff.rs +++ b/crates/edit_prediction/src/udiff.rs @@ -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?;