Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git_ui: Let branch and repo name use available panel width (#57502)

Matei Oprea949d9931462f
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index ef17b15cdea..3ef1b77edd8 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -6988,9 +6988,6 @@ impl RenderOnce for PanelRepoFooter {
.map(|project| project.read(cx).git_store().read(cx).repositories().len() == 1)
.unwrap_or(true);
- const MAX_BRANCH_LEN: usize = 16;
- const MAX_REPO_LEN: usize = 16;
- const LABEL_CHARACTER_BUDGET: usize = MAX_BRANCH_LEN + MAX_REPO_LEN;
const MAX_SHORT_SHA_LEN: usize = 8;
let branch_name = self
.branch
@@ -7010,36 +7007,6 @@ impl RenderOnce for PanelRepoFooter {
let active_repo_name = self.active_repository.clone();
- let branch_actual_len = branch_name.len();
- let repo_actual_len = active_repo_name.len();
-
- // ideally, show the whole branch and repo names but
- // when we can't, use a budget to allocate space between the two
- let (repo_display_len, branch_display_len) =
- if branch_actual_len + repo_actual_len <= LABEL_CHARACTER_BUDGET {
- (repo_actual_len, branch_actual_len)
- } else if branch_actual_len <= MAX_BRANCH_LEN {
- let repo_space = (LABEL_CHARACTER_BUDGET - branch_actual_len).min(MAX_REPO_LEN);
- (repo_space, branch_actual_len)
- } else if repo_actual_len <= MAX_REPO_LEN {
- let branch_space = (LABEL_CHARACTER_BUDGET - repo_actual_len).min(MAX_BRANCH_LEN);
- (repo_actual_len, branch_space)
- } else {
- (MAX_REPO_LEN, MAX_BRANCH_LEN)
- };
-
- let truncated_repo_name = if repo_actual_len <= repo_display_len {
- active_repo_name.to_string()
- } else {
- util::truncate_and_trailoff(active_repo_name.trim_ascii(), repo_display_len)
- };
-
- let truncated_branch_name = if branch_actual_len <= branch_display_len {
- branch_name
- } else {
- util::truncate_and_trailoff(branch_name.trim_ascii(), branch_display_len)
- };
-
let repo_selector = PopoverMenu::new("repository-switcher")
.menu({
let project = project;
@@ -7049,7 +7016,7 @@ impl RenderOnce for PanelRepoFooter {
}
})
.trigger_with_tooltip(
- Button::new("repo-selector", truncated_repo_name)
+ Button::new("repo-selector", active_repo_name)
.size(ButtonSize::None)
.label_size(LabelSize::Small)
.truncate(true),
@@ -7068,7 +7035,7 @@ impl RenderOnce for PanelRepoFooter {
})
.into_any_element();
- let branch_selector_button = Button::new("branch-selector", truncated_branch_name)
+ let branch_selector_button = Button::new("branch-selector", branch_name)
.size(ButtonSize::None)
.label_size(LabelSize::Small)
.truncate(true)
@@ -7111,15 +7078,16 @@ impl RenderOnce for PanelRepoFooter {
},
))
.when(!single_repo, |this| {
- this.child(repo_selector).when(show_separator, |this| {
- this.child(
- Label::new("/").size(LabelSize::Small).color(Color::Custom(
- cx.theme().colors().text_muted.opacity(0.4),
- )),
- )
- })
+ this.child(div().child(repo_selector).min_w_0()).when(
+ show_separator,
+ |this| {
+ this.child(Label::new("/").size(LabelSize::Small).color(
+ Color::Custom(cx.theme().colors().text_muted.opacity(0.4)),
+ ))
+ },
+ )
})
- .child(branch_selector),
+ .child(div().child(branch_selector).min_w_0()),
)
.children(if let Some(git_panel) = self.git_panel {
git_panel.update(cx, |git_panel, cx| git_panel.render_remote_button(cx))