From afb3fbff24c399014f0a23d21e815058685491e6 Mon Sep 17 00:00:00 2001 From: Bennet Bo Fenner Date: Thu, 15 Aug 2024 13:14:28 +0200 Subject: [PATCH] assistant panel: Make configuration view scrollable This is a manual port of https://github.com/zed-industries/zed/pull/16022. We'll need to revert this commit next wednesday before releasing a new stable version. --- crates/assistant/src/assistant_panel.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index d895bd1331b957dcd11ea4400ae1510456580ec1..eef0bd58bbb67b30e375db50082bd8c69830f1ff 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -3337,11 +3337,10 @@ impl Render for ConfigurationView { .map(|provider| self.render_provider_view(&provider, cx)) .collect::>(); - v_flex() + let mut element = v_flex() .id("assistant-configuration-view") .track_focus(&self.focus_handle) - .w_full() - .min_h_full() + .size_full() .p(Spacing::XXLarge.rems(cx)) .overflow_y_scroll() .gap_6() @@ -3359,8 +3358,23 @@ impl Render for ConfigurationView { ) .color(Color::Muted), ) - .child(v_flex().mt_2().gap_4().children(provider_views)), + .child(v_flex().flex_1().mt_2().gap_4().children(provider_views)), ) + .into_any(); + + // We use a canvas here to get scrolling to work in the ConfigurationView. It's a workaround + // because we couldn't the element to take up the size of the parent. + gpui::canvas( + move |bounds, cx| { + element.prepaint_as_root(bounds.origin, bounds.size.into(), cx); + element + }, + |_, mut element, cx| { + element.paint(cx); + }, + ) + .flex_1() + .w_full() } }