assistant2: Factor out ContextStrip
(#22096)
This PR factors a `ContextStrip` view out of the `MessageEditor` so that we can use it in other places. Release Notes: - N/A
This commit is contained in:
parent
ff2ad63037
commit
caefdcd7f1
7 changed files with 154 additions and 125 deletions
|
@ -13,7 +13,7 @@ use workspace::Workspace;
|
|||
|
||||
use crate::context::ContextKind;
|
||||
use crate::context_picker::ContextPicker;
|
||||
use crate::message_editor::MessageEditor;
|
||||
use crate::context_strip::ContextStrip;
|
||||
|
||||
pub struct FetchContextPicker {
|
||||
picker: View<Picker<FetchContextPickerDelegate>>,
|
||||
|
@ -23,10 +23,10 @@ impl FetchContextPicker {
|
|||
pub fn new(
|
||||
context_picker: WeakView<ContextPicker>,
|
||||
workspace: WeakView<Workspace>,
|
||||
message_editor: WeakView<MessageEditor>,
|
||||
context_strip: WeakView<ContextStrip>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> Self {
|
||||
let delegate = FetchContextPickerDelegate::new(context_picker, workspace, message_editor);
|
||||
let delegate = FetchContextPickerDelegate::new(context_picker, workspace, context_strip);
|
||||
let picker = cx.new_view(|cx| Picker::uniform_list(delegate, cx));
|
||||
|
||||
Self { picker }
|
||||
|
@ -55,7 +55,7 @@ enum ContentType {
|
|||
pub struct FetchContextPickerDelegate {
|
||||
context_picker: WeakView<ContextPicker>,
|
||||
workspace: WeakView<Workspace>,
|
||||
message_editor: WeakView<MessageEditor>,
|
||||
context_strip: WeakView<ContextStrip>,
|
||||
url: String,
|
||||
}
|
||||
|
||||
|
@ -63,12 +63,12 @@ impl FetchContextPickerDelegate {
|
|||
pub fn new(
|
||||
context_picker: WeakView<ContextPicker>,
|
||||
workspace: WeakView<Workspace>,
|
||||
message_editor: WeakView<MessageEditor>,
|
||||
context_strip: WeakView<ContextStrip>,
|
||||
) -> Self {
|
||||
FetchContextPickerDelegate {
|
||||
context_picker,
|
||||
workspace,
|
||||
message_editor,
|
||||
context_strip,
|
||||
url: String::new(),
|
||||
}
|
||||
}
|
||||
|
@ -189,9 +189,9 @@ impl PickerDelegate for FetchContextPickerDelegate {
|
|||
|
||||
this.update(&mut cx, |this, cx| {
|
||||
this.delegate
|
||||
.message_editor
|
||||
.update(cx, |message_editor, _cx| {
|
||||
message_editor.insert_context(ContextKind::FetchedUrl, url, text);
|
||||
.context_strip
|
||||
.update(cx, |context_strip, _cx| {
|
||||
context_strip.insert_context(ContextKind::FetchedUrl, url, text);
|
||||
})
|
||||
})??;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue