Skip to content

Commit 6f722b4

Browse files
author
Stephan Dilly
committed
fix branchname width misalignment
1 parent b5f1e76 commit 6f722b4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

src/components/branchlist.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ impl DrawableComponent for BranchListComponent {
4949
rect: Rect,
5050
) -> Result<()> {
5151
if self.visible {
52-
const PERCENT_SIZE: Size = Size::new(60, 25);
53-
const MIN_SIZE: Size = Size::new(50, 20);
52+
const PERCENT_SIZE: Size = Size::new(80, 25);
53+
const MIN_SIZE: Size = Size::new(60, 20);
5454

5555
let area = ui::centered_rect(
5656
PERCENT_SIZE.width,
@@ -338,9 +338,8 @@ impl BranchListComponent {
338338
const IS_HEAD_STAR_LENGTH: usize = 3; // "* "
339339
const THREE_DOTS_LENGTH: usize = 3; // "..."
340340

341-
// branch name = 30% of area size
342341
let branch_name_length: usize =
343-
width_available as usize * 30 / 100;
342+
width_available as usize * 40 / 100;
344343
// commit message takes up the remaining width
345344
let commit_message_length: usize = (width_available as usize)
346345
.saturating_sub(COMMIT_HASH_LENGTH)
@@ -367,11 +366,16 @@ impl BranchListComponent {
367366
}
368367

369368
let mut branch_name = displaybranch.name.clone();
370-
if branch_name.len() > branch_name_length {
371-
branch_name.unicode_truncate(
372-
branch_name_length
373-
.saturating_sub(THREE_DOTS_LENGTH),
374-
);
369+
if branch_name.len()
370+
> branch_name_length.saturating_sub(THREE_DOTS_LENGTH)
371+
{
372+
branch_name = branch_name
373+
.unicode_truncate(
374+
branch_name_length
375+
.saturating_sub(THREE_DOTS_LENGTH),
376+
)
377+
.0
378+
.to_string();
375379
branch_name += "...";
376380
}
377381

0 commit comments

Comments
 (0)