Make chat message list fill the available space

Max Brunsfeld created

Change summary

crates/collab_ui2/src/chat_panel.rs |  2 +-
crates/gpui2/src/elements/list.rs   | 12 ++++++++++--
crates/gpui2/src/gpui2.rs           |  5 +----
crates/rich_text2/src/rich_text.rs  |  2 +-
4 files changed, 13 insertions(+), 8 deletions(-)

Detailed changes

crates/collab_ui2/src/chat_panel.rs 🔗

@@ -345,7 +345,7 @@ impl ChatPanel {
 
     fn render_active_channel_messages(&self, _cx: &mut ViewContext<Self>) -> AnyElement {
         if self.active_chat.is_some() {
-            list(self.message_list.clone()).into_any_element()
+            list(self.message_list.clone()).full().into_any_element()
         } else {
             div().into_any_element()
         }

crates/gpui2/src/elements/list.rs 🔗

@@ -1,8 +1,9 @@
 use crate::{
     px, AnyElement, AvailableSpace, BorrowAppContext, DispatchPhase, Element, IntoElement, Pixels,
-    Point, ScrollWheelEvent, Size, Style, StyleRefinement, WindowContext,
+    Point, ScrollWheelEvent, Size, Style, StyleRefinement, Styled, WindowContext,
 };
 use collections::VecDeque;
+use refineable::Refineable as _;
 use std::{cell::RefCell, ops::Range, rc::Rc};
 use sum_tree::{Bias, SumTree};
 
@@ -247,7 +248,8 @@ impl Element for List {
         _state: Option<Self::State>,
         cx: &mut crate::WindowContext,
     ) -> (crate::LayoutId, Self::State) {
-        let style = Style::from(self.style.clone());
+        let mut style = Style::default();
+        style.refine(&self.style);
         let layout_id = cx.with_text_style(style.text_style().cloned(), |cx| {
             cx.request_layout(&style, None)
         });
@@ -419,6 +421,12 @@ impl IntoElement for List {
     }
 }
 
+impl Styled for List {
+    fn style(&mut self) -> &mut StyleRefinement {
+        &mut self.style
+    }
+}
+
 impl sum_tree::Item for ListItem {
     type Summary = ListItemSummary;
 

crates/gpui2/src/gpui2.rs 🔗

@@ -74,12 +74,9 @@ pub use util::arc_cow::ArcCow;
 pub use view::*;
 pub use window::*;
 
-use derive_more::{Deref, DerefMut};
-use serde::{Deserialize, Serialize};
 use std::{
     any::{Any, TypeId},
-    borrow::{Borrow, BorrowMut},
-    sync::Arc,
+    borrow::BorrowMut,
 };
 use taffy::TaffyLayoutEngine;
 

crates/rich_text2/src/rich_text.rs 🔗

@@ -56,7 +56,7 @@ pub struct Mention {
 }
 
 impl RichText {
-    pub fn element(&self, cx: &mut WindowContext) -> AnyElement {
+    pub fn element(&self, _cx: &mut WindowContext) -> AnyElement {
         todo!();
 
         // let mut region_id = 0;