Make repo and branch popovers extend up from their trigger buttons (#26950)

Previously, when clicking on the branch, the popover would obscure the
button you just clicked, which was awkward.

Release Notes:

- Improved the placement of the repo and branch picker popovers in the
git panel.
- Added a 'SelectRepo' action that opens the repository selector in a
modal.
This commit is contained in:
Max Brunsfeld 2025-03-17 15:05:17 -07:00 committed by GitHub
parent a05066cd83
commit 2b2b9c1624
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 59 additions and 49 deletions

View file

@ -7,7 +7,7 @@ use gpui::{
InteractiveElement, IntoElement, Modifiers, ModifiersChangedEvent, ParentElement, Render,
SharedString, Styled, Subscription, Task, Window,
};
use picker::{Picker, PickerDelegate};
use picker::{Picker, PickerDelegate, PickerEditorPosition};
use project::git::Repository;
use std::sync::Arc;
use time::OffsetDateTime;
@ -17,13 +17,10 @@ use util::ResultExt;
use workspace::notifications::DetachAndPromptErr;
use workspace::{ModalView, Workspace};
pub fn init(cx: &mut App) {
cx.observe_new(|workspace: &mut Workspace, _, _| {
workspace.register_action(open);
workspace.register_action(switch);
workspace.register_action(checkout_branch);
})
.detach();
pub fn register(workspace: &mut Workspace) {
workspace.register_action(open);
workspace.register_action(switch);
workspace.register_action(checkout_branch);
}
pub fn checkout_branch(
@ -225,6 +222,13 @@ impl PickerDelegate for BranchListDelegate {
"Select branch...".into()
}
fn editor_position(&self) -> PickerEditorPosition {
match self.style {
BranchListStyle::Modal => PickerEditorPosition::Start,
BranchListStyle::Popover => PickerEditorPosition::End,
}
}
fn match_count(&self) -> usize {
self.matches.len()
}