From f5b60adcf951092be9086ca769e5a337fa518fd9 Mon Sep 17 00:00:00 2001 From: Marshall Bowers Date: Tue, 2 Jan 2024 11:15:27 -0500 Subject: [PATCH] Increase outline picker max height (#3831) This PR increases the max height of the outline picker so that it can take up a larger area of the screen when there are lots of results. This behavior is similar to the way it was in Zed1. Release Notes: - N/A --- crates/outline2/src/outline.rs | 6 +++++- crates/picker2/src/picker2.rs | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/crates/outline2/src/outline.rs b/crates/outline2/src/outline.rs index 0446f42798..c5cfcfe66a 100644 --- a/crates/outline2/src/outline.rs +++ b/crates/outline2/src/outline.rs @@ -79,8 +79,12 @@ impl OutlineView { editor: View, cx: &mut ViewContext, ) -> OutlineView { + const MAX_HEIGHT_IN_VH: f32 = 0.75; + let delegate = OutlineViewDelegate::new(cx.view().downgrade(), outline, editor, cx); - let picker = cx.new_view(|cx| Picker::new(delegate, cx)); + let picker = cx.new_view(|cx| { + Picker::new(delegate, cx).max_height(cx.viewport_size().height * MAX_HEIGHT_IN_VH) + }); OutlineView { picker } } } diff --git a/crates/picker2/src/picker2.rs b/crates/picker2/src/picker2.rs index 546791a671..cee8fb74ff 100644 --- a/crates/picker2/src/picker2.rs +++ b/crates/picker2/src/picker2.rs @@ -15,6 +15,7 @@ pub struct Picker { pending_update_matches: Option>, confirm_on_update: Option, width: Option, + max_height: Option, /// Whether the `Picker` is rendered as a self-contained modal. /// @@ -72,6 +73,7 @@ impl Picker { pending_update_matches: None, confirm_on_update: None, width: None, + max_height: None, is_modal: true, }; this.update_matches("".to_string(), cx); @@ -83,6 +85,11 @@ impl Picker { self } + pub fn max_height(mut self, max_height: impl Into) -> Self { + self.max_height = Some(max_height.into()); + self + } + pub fn modal(mut self, modal: bool) -> Self { self.is_modal = modal; self @@ -260,6 +267,8 @@ impl Render for Picker { v_stack() .flex_grow() .py_2() + .max_h(self.max_height.unwrap_or(rems(18.).into())) + .overflow_hidden() .children(self.delegate.render_header(cx)) .child( uniform_list( @@ -296,8 +305,6 @@ impl Render for Picker { .track_scroll(self.scroll_handle.clone()) ) - .max_h_72() - .overflow_hidden(), ) }) .when(self.delegate.match_count() == 0, |el| {