From c56b8904ccf5c44d608898ccd84dad7934db1531 Mon Sep 17 00:00:00 2001 From: ddoemonn <109994179+ddoemonn@users.noreply.github.com> Date: Sat, 28 Jun 2025 02:50:53 +0300 Subject: [PATCH] Prevent branch name overflow in git panel selection (#33529) Closes #33527 Release Notes: - Fixed long branch names overflowing to multiple lines in git panel branch selector --------- Co-authored-by: Danilo Leal --- crates/git_ui/src/branch_picker.rs | 55 +++++++++++++++--------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/crates/git_ui/src/branch_picker.rs b/crates/git_ui/src/branch_picker.rs index 635876dace..9eac3ce5af 100644 --- a/crates/git_ui/src/branch_picker.rs +++ b/crates/git_ui/src/branch_picker.rs @@ -245,7 +245,7 @@ impl PickerDelegate for BranchListDelegate { type ListItem = ListItem; fn placeholder_text(&self, _window: &mut Window, _cx: &mut App) -> Arc { - "Select branch...".into() + "Select branch…".into() } fn editor_position(&self) -> PickerEditorPosition { @@ -439,44 +439,43 @@ impl PickerDelegate for BranchListDelegate { }) .unwrap_or_else(|| (None, None)); + let branch_name = if entry.is_new { + h_flex() + .gap_1() + .child( + Icon::new(IconName::Plus) + .size(IconSize::Small) + .color(Color::Muted), + ) + .child( + Label::new(format!("Create branch \"{}\"…", entry.branch.name())) + .single_line() + .truncate(), + ) + .into_any_element() + } else { + HighlightedLabel::new(entry.branch.name().to_owned(), entry.positions.clone()) + .truncate() + .into_any_element() + }; + Some( ListItem::new(SharedString::from(format!("vcs-menu-{ix}"))) .inset(true) - .spacing(match self.style { - BranchListStyle::Modal => ListItemSpacing::default(), - BranchListStyle::Popover => ListItemSpacing::ExtraDense, - }) .spacing(ListItemSpacing::Sparse) .toggle_state(selected) .child( v_flex() .w_full() + .overflow_hidden() .child( h_flex() - .w_full() - .flex_shrink() - .overflow_x_hidden() - .gap_2() + .gap_6() .justify_between() - .child(div().flex_shrink().overflow_x_hidden().child( - if entry.is_new { - Label::new(format!( - "Create branch \"{}\"…", - entry.branch.name() - )) - .single_line() - .into_any_element() - } else { - HighlightedLabel::new( - entry.branch.name().to_owned(), - entry.positions.clone(), - ) - .truncate() - .into_any_element() - }, - )) - .when_some(commit_time, |el, commit_time| { - el.child( + .overflow_x_hidden() + .child(branch_name) + .when_some(commit_time, |label, commit_time| { + label.child( Label::new(commit_time) .size(LabelSize::Small) .color(Color::Muted)