Improve workflow prompt, accept nonexistent directories from workflows (#16251)

Release Notes:

- Workflows can now create new files in folders that didn't exist

---------

Co-authored-by: jvmncs <7891333+jvmncs@users.noreply.github.com>
This commit is contained in:
Richard Feldman 2024-08-14 18:18:41 -04:00 committed by GitHub
parent a6461f90a1
commit 796cba9e0e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 285 additions and 55 deletions

View file

@ -3802,6 +3802,7 @@ mod tests {
mod tool {
use gpui::AsyncAppContext;
use project::ProjectPath;
use super::*;
@ -3862,6 +3863,20 @@ mod tool {
.update(&mut cx, |project, cx| {
let project_path = project
.find_project_path(Path::new(&path), cx)
.or_else(|| {
// If we couldn't find a project path for it, put it in the active worktree
// so that when we create the buffer, it can be saved.
let worktree = project
.active_entry()
.and_then(|entry_id| project.worktree_for_entry(entry_id, cx))
.or_else(|| project.worktrees(cx).next())?;
let worktree = worktree.read(cx);
Some(ProjectPath {
worktree_id: worktree.id(),
path: Arc::from(Path::new(&path)),
})
})
.with_context(|| format!("worktree not found for {:?}", path))?;
anyhow::Ok(project.open_buffer(project_path, cx))
})??