Skip to content

Commit

Permalink
Fix breadcrumb
Browse files Browse the repository at this point in the history
  • Loading branch information
lusingander committed Feb 28, 2025
1 parent 6d09bc7 commit 51330bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ pub fn prune_strings_to_fit_width(
) -> Vec<String> {
let words_total_length = words_with_priority
.iter()
.map(|(s, _)| s.len())
.map(|(s, _)| console::measure_text_width(s))
.sum::<usize>();
let delimiter_total_length = words_with_priority.len().saturating_sub(1) * delimiter.len();
let delimiter_len = console::measure_text_width(delimiter);
let delimiter_total_length = words_with_priority.len().saturating_sub(1) * delimiter_len;
let mut total_length = words_total_length + delimiter_total_length;

let mut words_with_priority_with_index: Vec<(usize, &(String, usize))> =
Expand All @@ -21,8 +22,8 @@ pub fn prune_strings_to_fit_width(
break;
}
prune.push(*i);
total_length -= s.len();
total_length -= delimiter.len();
total_length -= console::measure_text_width(s);
total_length -= delimiter_len;
}

words_with_priority
Expand Down
2 changes: 1 addition & 1 deletion src/widget/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Header {
}

let current_key = self.breadcrumb.join(Self::DELIMITER);
if current_key.len() <= max_width {
if console::measure_text_width(&current_key) <= max_width {
return current_key;
}

Expand Down

0 comments on commit 51330bc

Please sign in to comment.