Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Fix picker new_path_prompt throwing "file exists" when saving (#21080)

Peter Tripp1a0a8a9559cf
diff --git a/crates/file_finder/src/new_path_prompt.rs b/crates/file_finder/src/new_path_prompt.rs
index d4492857b49..6a1b08e2056 100644
--- a/crates/file_finder/src/new_path_prompt.rs
+++ b/crates/file_finder/src/new_path_prompt.rs
@@ -71,8 +71,16 @@ impl Match {
fn project_path(&self, project: &Project, cx: &WindowContext) -> Option<ProjectPath> {
let worktree_id = if let Some(path_match) = &self.path_match {
WorktreeId::from_usize(path_match.worktree_id)
+ } else if let Some(worktree) = project.visible_worktrees(cx).find(|worktree| {
+ worktree
+ .read(cx)
+ .root_entry()
+ .is_some_and(|entry| entry.is_dir())
+ }) {
+ worktree.read(cx).id()
} else {
- project.worktrees(cx).next()?.read(cx).id()
+ // todo(): we should find_or_create a workspace.
+ return None;
};
let path = PathBuf::from(self.relative_path());