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 <daniloleal09@gmail.com>
This commit is contained in:
parent
695118d110
commit
c56b8904cc
1 changed files with 27 additions and 28 deletions
|
@ -245,7 +245,7 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
type ListItem = ListItem;
|
type ListItem = ListItem;
|
||||||
|
|
||||||
fn placeholder_text(&self, _window: &mut Window, _cx: &mut App) -> Arc<str> {
|
fn placeholder_text(&self, _window: &mut Window, _cx: &mut App) -> Arc<str> {
|
||||||
"Select branch...".into()
|
"Select branch…".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn editor_position(&self) -> PickerEditorPosition {
|
fn editor_position(&self) -> PickerEditorPosition {
|
||||||
|
@ -439,44 +439,43 @@ impl PickerDelegate for BranchListDelegate {
|
||||||
})
|
})
|
||||||
.unwrap_or_else(|| (None, None));
|
.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(
|
Some(
|
||||||
ListItem::new(SharedString::from(format!("vcs-menu-{ix}")))
|
ListItem::new(SharedString::from(format!("vcs-menu-{ix}")))
|
||||||
.inset(true)
|
.inset(true)
|
||||||
.spacing(match self.style {
|
|
||||||
BranchListStyle::Modal => ListItemSpacing::default(),
|
|
||||||
BranchListStyle::Popover => ListItemSpacing::ExtraDense,
|
|
||||||
})
|
|
||||||
.spacing(ListItemSpacing::Sparse)
|
.spacing(ListItemSpacing::Sparse)
|
||||||
.toggle_state(selected)
|
.toggle_state(selected)
|
||||||
.child(
|
.child(
|
||||||
v_flex()
|
v_flex()
|
||||||
.w_full()
|
.w_full()
|
||||||
|
.overflow_hidden()
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.w_full()
|
.gap_6()
|
||||||
.flex_shrink()
|
|
||||||
.overflow_x_hidden()
|
|
||||||
.gap_2()
|
|
||||||
.justify_between()
|
.justify_between()
|
||||||
.child(div().flex_shrink().overflow_x_hidden().child(
|
.overflow_x_hidden()
|
||||||
if entry.is_new {
|
.child(branch_name)
|
||||||
Label::new(format!(
|
.when_some(commit_time, |label, commit_time| {
|
||||||
"Create branch \"{}\"…",
|
label.child(
|
||||||
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(
|
|
||||||
Label::new(commit_time)
|
Label::new(commit_time)
|
||||||
.size(LabelSize::Small)
|
.size(LabelSize::Small)
|
||||||
.color(Color::Muted)
|
.color(Color::Muted)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue