From 173f6e7c8f9848d7dd52785f223b8c1e91bc06f8 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Fri, 9 Aug 2024 12:21:22 +0200 Subject: [PATCH] assistant panel: Make configuration view scrollable (#16022) We had to resort to this "hack" to get it to work, since nothing else we tried (changing the `Pane`, changing the `ConfigurationView`, changing the `AssistantPanel`, ...) worked. Release Notes: - N/A Co-authored-by: Antonio Co-authored-by: Bennet --- crates/assistant/src/assistant_panel.rs | 31 ++++++++++++++++++------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index 51c1e8c747..ca74c06816 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -32,12 +32,12 @@ use editor::{ use editor::{display_map::CreaseId, FoldPlaceholder}; use fs::Fs; use gpui::{ - div, percentage, point, Action, Animation, AnimationExt, AnyElement, AnyView, AppContext, - AsyncWindowContext, ClipboardItem, Context as _, DismissEvent, Empty, Entity, EntityId, - EventEmitter, FocusHandle, FocusableView, FontWeight, InteractiveElement, IntoElement, Model, - ParentElement, Pixels, ReadGlobal, Render, SharedString, StatefulInteractiveElement, Styled, - Subscription, Task, Transformation, UpdateGlobal, View, ViewContext, VisualContext, WeakView, - WindowContext, + canvas, div, percentage, point, Action, Animation, AnimationExt, AnyElement, AnyView, + AppContext, AsyncWindowContext, ClipboardItem, Context as _, DismissEvent, Empty, Entity, + EntityId, EventEmitter, FocusHandle, FocusableView, FontWeight, InteractiveElement, + IntoElement, Model, ParentElement, Pixels, ReadGlobal, Render, SharedString, + StatefulInteractiveElement, Styled, Subscription, Task, Transformation, UpdateGlobal, View, + ViewContext, VisualContext, WeakView, WindowContext, }; use indexed_docs::IndexedDocsStore; use language::{ @@ -3945,7 +3945,7 @@ 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) .bg(cx.theme().colors().editor_background) @@ -3970,9 +3970,24 @@ impl Render for ConfigurationView { .p(Spacing::XXLarge.rems(cx)) .mt_1() .gap_6() - .size_full() + .flex_1() .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. + 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() } }