Use correct worktree when getting permalink to line (#8888)

Previously this code would call `project.visible_worktrees(cx).next`
which might not necessarily return the worktree matching the currently
open file.

What this change does is it adds `get_repo` method on `Project` that
allows us to get the `GitRepository` for the current buffer.

Release Notes:

- Fixed `open permalink to line` not working when multiple folders are
added to the project.

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Thorsten Ball 2024-03-05 16:59:00 +01:00 committed by GitHub
parent d286c56ebb
commit 2b8b913b6b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 22 deletions

View file

@ -2116,6 +2116,11 @@ impl LocalSnapshot {
Some((path, self.git_repositories.get(&repo.work_directory_id())?))
}
pub fn local_git_repo(&self, path: &Path) -> Option<Arc<Mutex<dyn GitRepository>>> {
self.local_repo_for_path(path)
.map(|(_, entry)| entry.repo_ptr.clone())
}
fn build_update(
&self,
project_id: u64,