Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
assistant2: Use `ContextKind` to match on `ContextPicker` entries (#22143)
Marshall Bowers68e3d79847d2
diff --git a/crates/assistant2/src/context_picker.rs b/crates/assistant2/src/context_picker.rsindex 48bb30a5f52..f6a49d02814 100644--- a/crates/assistant2/src/context_picker.rs+++ b/crates/assistant2/src/context_picker.rs@@ -13,6 +13,7 @@ use ui::{prelude::*, ListItem, ListItemSpacing};use util::ResultExt;use workspace::Workspace;+use crate::context::ContextKind;use crate::context_picker::fetch_context_picker::FetchContextPicker;use crate::context_picker::file_context_picker::FileContextPicker;use crate::context_picker::thread_context_picker::ThreadContextPicker;@@ -40,16 +41,14 @@ impl ContextPicker {cx: &mut ViewContext<Self>,) -> Self {let mut entries = vec![- ContextPickerEntry {- name: "Directory".into(),- icon: IconName::Folder,- },ContextPickerEntry {name: "File".into(),+ kind: ContextKind::File,icon: IconName::File,},ContextPickerEntry {name: "Fetch".into(),+ kind: ContextKind::FetchedUrl,icon: IconName::Globe,},];@@ -57,6 +56,7 @@ impl ContextPicker {if thread_store.is_some() {entries.push(ContextPickerEntry {name: "Thread".into(),+ kind: ContextKind::Thread,icon: IconName::MessageCircle,});}@@ -115,6 +115,7 @@ impl Render for ContextPicker {#[derive(Clone)]struct ContextPickerEntry {name: SharedString,+ kind: ContextKind,icon: IconName,}@@ -155,8 +156,8 @@ impl PickerDelegate for ContextPickerDelegate {if let Some(entry) = self.entries.get(self.selected_ix) {self.context_picker.update(cx, |this, cx| {- match entry.name.to_string().as_str() {- "File" => {+ match entry.kind {+ ContextKind::File => {this.mode = ContextPickerMode::File(cx.new_view(|cx| {FileContextPicker::new(self.context_picker.clone(),@@ -166,7 +167,7 @@ impl PickerDelegate for ContextPickerDelegate {)}));}- "Fetch" => {+ ContextKind::FetchedUrl => {this.mode = ContextPickerMode::Fetch(cx.new_view(|cx| {FetchContextPicker::new(self.context_picker.clone(),@@ -176,7 +177,7 @@ impl PickerDelegate for ContextPickerDelegate {)}));}- "Thread" => {+ ContextKind::Thread => {if let Some(thread_store) = self.thread_store.as_ref() {this.mode = ContextPickerMode::Thread(cx.new_view(|cx| {ThreadContextPicker::new(@@ -188,7 +189,6 @@ impl PickerDelegate for ContextPickerDelegate {}));}}- _ => {}}cx.focus_self();