Improve terminal.working_directory for non-project files (#18251)

This commit is contained in:
Peter Tripp 2024-11-13 15:40:36 +00:00 committed by GitHub
parent 27dfb48a7b
commit eb4e7472e6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 8 deletions

View file

@ -46,12 +46,16 @@ impl Project {
let worktree = self
.active_entry()
.and_then(|entry_id| self.worktree_for_entry(entry_id, cx))
.or_else(|| self.worktrees(cx).next())?;
let worktree = worktree.read(cx);
if !worktree.root_entry()?.is_dir() {
return None;
}
Some(worktree.abs_path().to_path_buf())
.into_iter()
.chain(self.worktrees(cx))
.find_map(|tree| {
let worktree = tree.read(cx);
worktree
.root_entry()
.filter(|entry| entry.is_dir())
.map(|_| worktree.abs_path().to_path_buf())
});
worktree
}
pub fn first_project_directory(&self, cx: &AppContext) -> Option<PathBuf> {