diff --git a/crates/signed_app/src/repo/commit_diff.rs b/crates/signed_app/src/repo/commit_diff.rs index 2280ccc..c16c3ec 100644 --- a/crates/signed_app/src/repo/commit_diff.rs +++ b/crates/signed_app/src/repo/commit_diff.rs @@ -322,7 +322,10 @@ impl Render for DiffPane { Resizable::new("commit-diff-split", self.split.clone()) .axis(Axis::Horizontal) .pane_with_min(tree, px(120.)) - .pane_with_min(detail, px(240.)), + .pane_with_min(detail, px(240.)) + .flex_1() + .min_w_0() + .h_full(), ) } } diff --git a/crates/signed_app/src/repo/refs.rs b/crates/signed_app/src/repo/refs.rs index 20f0439..2b7a9f2 100644 --- a/crates/signed_app/src/repo/refs.rs +++ b/crates/signed_app/src/repo/refs.rs @@ -1,5 +1,6 @@ use gpui::{App, AppContext as _, Entity, SharedString, WeakEntity, Window}; use ui::combobox::{Combobox, ComboboxState}; +use ui::icons::{IconRole, icon}; use super::RepoDetailView; use super::helpers::sync_selector; @@ -19,6 +20,7 @@ impl RefSwitcher { ComboboxState::new( Combobox::new("branch-select", "Branch", Vec::new()) .placeholder("Branch") + .selected_icon(icon(IconRole::GitBranch)) .on_change(move |value, window, cx| { if let Some(name) = value && let Err(error) = branch_view.update(cx, |this, cx| { diff --git a/crates/ui/src/components/button.rs b/crates/ui/src/components/button.rs index 6936b83..50c70da 100644 --- a/crates/ui/src/components/button.rs +++ b/crates/ui/src/components/button.rs @@ -356,7 +356,7 @@ impl RenderOnce for Button { .when_some(a11y_label, |button, label| button.aria_label(label)) .child( h_flex() - .gap_2() + .gap_1() .when(self.full_width, |content| content.flex_1()) .when(self.loading, |content| content.invisible()) .map(|content| { diff --git a/crates/ui/src/components/combobox.rs b/crates/ui/src/components/combobox.rs index ce19d47..4f9fd31 100644 --- a/crates/ui/src/components/combobox.rs +++ b/crates/ui/src/components/combobox.rs @@ -43,7 +43,7 @@ use crate::components::common::{ }; use crate::components::empty_state::EmptyState; use crate::components::input::{Input, InputState, InputStateEvent}; -use crate::icons::{IconRole, icon}; +use crate::icons::{Icon, IconRole, icon}; use crate::theme::{ActiveTheme as _, COMBOBOX_MIN_WIDTH, COMBOBOX_WIDTH, POPUP_MAX_HEIGHT, Size}; actions!( @@ -106,6 +106,8 @@ where filter: Option>, unmatched: UnmatchedText, size: Size, + /// Icon shown at the field's leading edge while a value is selected. + selected_icon: Option, style: StyleRefinement, } @@ -129,6 +131,7 @@ where filter: None, unmatched: UnmatchedText::default(), size: Size::default(), + selected_icon: None, style: StyleRefinement::default(), } } @@ -151,6 +154,12 @@ where self } + /// Shows an icon at the field's leading edge while a value is selected. + pub fn selected_icon(mut self, icon: Icon) -> Self { + self.selected_icon = Some(icon); + self + } + /// Reports the value whenever it changes. pub fn on_change(mut self, handler: F) -> Self where @@ -247,6 +256,8 @@ where size: Size, /// Width refinements from the builder, applied to the wrapper each render. style: StyleRefinement, + /// Icon shown at the field's leading edge while a value is selected. + selected_icon: Option, /// The row list's scroll, kept across frames while the popup is open. rows_scroll: UniformListScrollHandle, /// The most recent handler report in flight; a newer report replaces it. @@ -308,6 +319,7 @@ where unmatched: combobox.unmatched, size: combobox.size, style: combobox.style, + selected_icon: combobox.selected_icon, rows_scroll: UniformListScrollHandle::new(), task: None, _subscription: subscription, @@ -336,7 +348,15 @@ where /// Replaces the value; reports it when it actually changed. pub fn set_selected(&mut self, value: Option, window: &mut Window, cx: &mut Context) { + let changed = self.selected != value; self.set_value(value, window, cx); + if changed { + let label = self.selected_label().unwrap_or_default(); + self.query + .update(cx, |query, cx| query.set_value_silent(label, window, cx)); + self.refilter(""); + cx.notify(); + } } /// Replaces the choice list and re-runs the current filter. @@ -598,6 +618,12 @@ where Input::new((id.clone(), "query"), self.query.clone()) .placeholder(self.placeholder.clone()) .placeholder_when_focused(true) + .fully_rounded(true) + .when_some(self.selected_icon.clone(), |input, selected_icon| { + input.when(self.selected.is_some(), |input| { + input.prefix(selected_icon.size(self.size.icon_rems())) + }) + }) .with_size(self.size), ) .child( @@ -617,7 +643,7 @@ where let size = self.size; let list_state = state.clone(); let rows_id = id.clone(); - let radius_sm = radius.sm; + let radius_full = radius.full; let foreground = colors.foreground; // Rows are `control_height`, so the row height follows the size. @@ -654,6 +680,7 @@ where }) .role(Role::ListBoxOption) .aria_label(label.clone()) + .w_full() .flex() .items_center() .gap_2() @@ -661,7 +688,7 @@ where .py_1() .h(row_height) .control_text(size) - .rounded(radius_sm) + .rounded(radius_full) .map(|row| paint_highlighted_row(cx, row, highlighted, false)) .on_mouse_move({ let state = state.clone();