vsc menu: Fix issue when switching branch while non-visible worktree is open (#19888)

Fixes a regression introduced in #19755

<img width="935" alt="Screenshot 2024-10-29 at 12 13 04"
src="https://github.com/user-attachments/assets/7699b8da-631d-4932-89a8-bc5d7f2546f1">

Co-Authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- Fixed an issue where the branch switcher would show an error, when
opening a file outside of the project

Co-authored-by: Thorsten <thorsten@zed.dev>
This commit is contained in:
Bennet Bo Fenner 2024-10-29 12:27:30 +01:00 committed by GitHub
parent 6a0bcca9ec
commit 21b58643fa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -242,7 +242,7 @@ impl PickerDelegate for BranchListDelegate {
BranchEntry::NewBranch { name: branch_name } => branch_name, BranchEntry::NewBranch { name: branch_name } => branch_name,
}; };
let worktree = project let worktree = project
.worktrees(cx) .visible_worktrees(cx)
.next() .next()
.context("worktree disappeared")?; .context("worktree disappeared")?;
let repository = ProjectPath::root_path(worktree.read(cx).id()); let repository = ProjectPath::root_path(worktree.read(cx).id());