Allow scrolling saved conversations
This commit is contained in:
parent
b0ee7b2fb9
commit
e2a4474200
2 changed files with 39 additions and 17 deletions
|
@ -29,12 +29,12 @@ use editor::{
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
div, point, relative, rems, uniform_list, Action, AnyElement, AppContext, AsyncWindowContext,
|
canvas, div, point, relative, rems, uniform_list, Action, AnyElement, AppContext,
|
||||||
ClipboardItem, Context, Div, EventEmitter, FocusHandle, Focusable, FocusableView, FontStyle,
|
AsyncWindowContext, AvailableSpace, ClipboardItem, Context, Div, EventEmitter, FocusHandle,
|
||||||
FontWeight, HighlightStyle, InteractiveElement, IntoElement, Model, ModelContext,
|
Focusable, FocusableView, FontStyle, FontWeight, HighlightStyle, InteractiveElement,
|
||||||
ParentElement, Pixels, PromptLevel, Render, SharedString, StatefulInteractiveElement, Styled,
|
IntoElement, Model, ModelContext, ParentElement, Pixels, PromptLevel, Render, SharedString,
|
||||||
Subscription, Task, TextStyle, UniformListScrollHandle, View, ViewContext, VisualContext,
|
StatefulInteractiveElement, Styled, Subscription, Task, TextStyle, UniformListScrollHandle,
|
||||||
WeakModel, WeakView, WhiteSpace, WindowContext,
|
View, ViewContext, VisualContext, WeakModel, WeakView, WhiteSpace, WindowContext,
|
||||||
};
|
};
|
||||||
use language::{language_settings::SoftWrap, Buffer, LanguageRegistry, ToOffset as _};
|
use language::{language_settings::SoftWrap, Buffer, LanguageRegistry, ToOffset as _};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
|
@ -1184,17 +1184,28 @@ impl Render for AssistantPanel {
|
||||||
.child(if let Some(editor) = self.active_editor() {
|
.child(if let Some(editor) = self.active_editor() {
|
||||||
editor.clone().into_any_element()
|
editor.clone().into_any_element()
|
||||||
} else {
|
} else {
|
||||||
uniform_list(
|
let view = cx.view().clone();
|
||||||
cx.view().clone(),
|
let scroll_handle = self.saved_conversations_scroll_handle.clone();
|
||||||
"saved_conversations",
|
let conversation_count = self.saved_conversations.len();
|
||||||
self.saved_conversations.len(),
|
canvas(move |bounds, cx| {
|
||||||
|this, range, cx| {
|
uniform_list(
|
||||||
range
|
view,
|
||||||
.map(|ix| this.render_saved_conversation(ix, cx))
|
"saved_conversations",
|
||||||
.collect()
|
conversation_count,
|
||||||
},
|
|this, range, cx| {
|
||||||
)
|
range
|
||||||
.track_scroll(self.saved_conversations_scroll_handle.clone())
|
.map(|ix| this.render_saved_conversation(ix, cx))
|
||||||
|
.collect()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.track_scroll(scroll_handle)
|
||||||
|
.draw(
|
||||||
|
bounds.origin,
|
||||||
|
bounds.size,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
})
|
||||||
|
.size_full()
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,6 +23,17 @@ pub trait IntoElement: Sized {
|
||||||
self.into_element().into_any()
|
self.into_element().into_any()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw<T>(self, origin: Point<Pixels>, available_space: Size<T>, cx: &mut WindowContext)
|
||||||
|
where
|
||||||
|
T: Clone + Default + Debug + Into<AvailableSpace>,
|
||||||
|
{
|
||||||
|
let element = DrawableElement {
|
||||||
|
element: Some(self.into_element()),
|
||||||
|
phase: ElementDrawPhase::Start,
|
||||||
|
};
|
||||||
|
DrawableElement::draw(element, origin, available_space.map(Into::into), cx);
|
||||||
|
}
|
||||||
|
|
||||||
fn draw_and_update_state<T, R>(
|
fn draw_and_update_state<T, R>(
|
||||||
self,
|
self,
|
||||||
origin: Point<Pixels>,
|
origin: Point<Pixels>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue