consolidate shared helpers into utils crate

This commit is contained in:
2026-10-03 11:00:59 +07:00
parent 24070cc2cd
commit d00ee33eab
16 changed files with 89 additions and 177 deletions
@@ -30,6 +30,7 @@ use signed_state::{
Backend, CheckoutsStore, RepoListStore, RepoStore, ensure_repo_mirror, repo_mirror_path,
};
use signed_ui::{CountBadge, placeholder, ref_selector_trigger};
use utils::middle_truncate;
use crate::views::commit_diff::{COMMIT_ROW_HEIGHT, CommitDiffView, DiffPane, commit_row};
use crate::views::{repo_tab_avatar, tab_title};
@@ -104,17 +105,8 @@ fn shorten_owner(owner: &PublicKey) -> String {
hex.chars().take(10).collect()
}
/// Truncate a label for the fixed-width controls of the compare bar.
fn truncate_label(label: &str) -> SharedString {
const MAX: usize = 18;
let mut chars = label.chars();
let (prefix, rest) = (chars.by_ref().take(MAX).collect::<String>(), chars.next());
let label = if rest.is_some() {
format!("{}…", &prefix[..prefix.len().saturating_sub(1)])
} else {
prefix
};
SharedString::from(label)
SharedString::from(middle_truncate(label, 18, 0))
}
fn checkout_source_item(