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 <conrad@zed.dev>
This commit is contained in:
Peter Tripp 2024-11-22 22:45:03 +00:00 committed by GitHub
parent 2fd210bc9a
commit 1a0a8a9559
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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());