Trim branch for larger names

This commit is contained in:
Alvaro Parker 2025-08-17 19:25:56 -04:00
parent 33fd16c749
commit 66c4e3fe3e
No known key found for this signature in database

View file

@ -440,14 +440,18 @@ impl PickerDelegate for StashListDelegate {
let stash_name = HighlightedLabel::new(stash_message, positions).into_any_element(); let stash_name = HighlightedLabel::new(stash_message, positions).into_any_element();
let stash_index_label = Label::new( let mut branch_name = entry_match.entry.branch.clone().unwrap_or_default();
entry_match let max_branch_chars = ((max_width * 0.2) / normal_em) as usize;
.entry if branch_name.len() > max_branch_chars && max_branch_chars > 1 {
.branch let mut index = max_branch_chars - 1;
.clone() while !branch_name.is_char_boundary(index) && index != 0 {
.unwrap_or_default() index -= 1;
.to_string(), }
) branch_name.truncate(index);
branch_name.push_str("");
}
let stash_index_label = Label::new(branch_name)
.size(LabelSize::Small) .size(LabelSize::Small)
.color(Color::Muted); .color(Color::Muted);