From 1a0a8a9559cf0a63f4be7c564603b7da78101b57 Mon Sep 17 00:00:00 2001 From: Peter Tripp Date: Fri, 22 Nov 2024 22:45:03 +0000 Subject: [PATCH] Fix picker new_path_prompt throwing "file exists" when saving (#21080) Fix for getting File exists "os error 17" with `"use_system_path_prompts": false,` This was reproducible when the first worktree is a non-folder worktree (e.g. setting.json) so we were trying to create the new file with a path under ~/.config/zed/settings.json/newfile.ext Co-authored-by: Conrad Irwin --- crates/file_finder/src/new_path_prompt.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/file_finder/src/new_path_prompt.rs b/crates/file_finder/src/new_path_prompt.rs index d4492857b4..6a1b08e205 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 { 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());