From c7399064131024de251801d1760ff4c5b24005ce Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Fri, 8 Dec 2023 12:27:45 -0800 Subject: [PATCH] Make chat message list fill the available space --- 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(-) diff --git a/crates/collab_ui2/src/chat_panel.rs b/crates/collab_ui2/src/chat_panel.rs index 73d8bd67755d2e399f1e9797cf6b9951b4d1ae77..4a8f255f6961fa05df9a07956e797ca0ec503ca6 100644 --- a/crates/collab_ui2/src/chat_panel.rs +++ b/crates/collab_ui2/src/chat_panel.rs @@ -345,7 +345,7 @@ impl ChatPanel { fn render_active_channel_messages(&self, _cx: &mut ViewContext) -> 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() } diff --git a/crates/gpui2/src/elements/list.rs b/crates/gpui2/src/elements/list.rs index a2dcb6ed61f9f6ef00e97c2c1d78261ed986f345..ba479e1ea8f460ecf5915661f877a89f132f288d 100644 --- a/crates/gpui2/src/elements/list.rs +++ b/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, 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; diff --git a/crates/gpui2/src/gpui2.rs b/crates/gpui2/src/gpui2.rs index fedea33400f1ef774ebfcff5602f38000f0e16f4..c711d1f5a2d38daeff8bcd86e90595a48114f601 100644 --- a/crates/gpui2/src/gpui2.rs +++ b/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; diff --git a/crates/rich_text2/src/rich_text.rs b/crates/rich_text2/src/rich_text.rs index fd73e95b74dcf531a472ad2702c60e7a5deaf425..263a7f311b283bb1e6092e280a80b47ada81fc59 100644 --- a/crates/rich_text2/src/rich_text.rs +++ b/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;