diff --git a/Cargo.lock b/Cargo.lock index cdb1fb5899..989a4c9c5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16012,7 +16012,6 @@ dependencies = [ "outline_panel", "parking_lot", "paths", - "picker", "profiling", "project", "project_panel", diff --git a/crates/repl/src/components/kernel_options.rs b/crates/repl/src/components/kernel_options.rs index 20b1c9d596..407fc4643b 100644 --- a/crates/repl/src/components/kernel_options.rs +++ b/crates/repl/src/components/kernel_options.rs @@ -1,6 +1,5 @@ use crate::kernels::KernelSpecification; use crate::repl_store::ReplStore; -use crate::worktree_id_for_editor; use crate::KERNEL_DOCS_URL; use editor::Editor; @@ -19,7 +18,7 @@ use ui::ListItemSpacing; use gpui::SharedString; use gpui::Task; -use ui::{prelude::*, ListItem, PopoverMenu, PopoverMenuHandle, PopoverTrigger}; +use ui::{prelude::*, ListItem, PopoverMenu, PopoverMenuHandle}; pub type OnSelect = Box; @@ -49,10 +48,11 @@ fn truncate_path(path: &SharedString, max_length: usize) -> SharedString { } impl KernelSelector { - pub fn new(editor: WeakView, cx: &mut ViewContext) -> Self { - // todo!() - let worktree_id = worktree_id_for_editor(editor.clone(), cx).unwrap(); - + pub fn new( + worktree_id: WorktreeId, + editor: WeakView, + _cx: &mut ViewContext, + ) -> Self { KernelSelector { editor, handle: None, @@ -324,7 +324,6 @@ impl KernelPickerDelegate { } fn set_group(&mut self, group: Group, cx: &mut ViewContext>) { - dbg!(&group); self.group = group; cx.notify(); } diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.toml index 1fbdcbab6f..40b75081ed 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -80,7 +80,6 @@ outline.workspace = true outline_panel.workspace = true parking_lot.workspace = true paths.workspace = true -picker.workspace = true profiling.workspace = true project.workspace = true project_panel.workspace = true diff --git a/crates/zed/src/zed/quick_action_bar.rs b/crates/zed/src/zed/quick_action_bar.rs index 811d4c07b5..0e3bd1bdf5 100644 --- a/crates/zed/src/zed/quick_action_bar.rs +++ b/crates/zed/src/zed/quick_action_bar.rs @@ -13,6 +13,7 @@ use gpui::{ Action, AnchorCorner, ClickEvent, ElementId, EventEmitter, FocusHandle, FocusableView, InteractiveElement, ParentElement, Render, Styled, Subscription, View, ViewContext, WeakView, }; +use repl::worktree_id_for_editor; use repl_menu::ReplMenu; use search::{buffer_search, BufferSearchBar}; use settings::{Settings, SettingsStore}; @@ -428,8 +429,15 @@ impl ToolbarItemView for QuickActionBar { if let Some(active_item) = active_pane_item { self._inlay_hints_enabled_subscription.take(); - if let Some(editor) = active_item.downcast::() { - self.repl_menu = Some(cx.new_view(|cx| ReplMenu::new(editor.downgrade(), cx))); + let editor = active_item.downcast::(); + + let work_tree_id = active_item + .downcast::() + .and_then(|editor| worktree_id_for_editor(editor.downgrade(), cx)); + + if let (Some(editor), Some(work_tree_id)) = (editor, work_tree_id) { + self.repl_menu = + Some(cx.new_view(|cx| ReplMenu::new(work_tree_id, editor.downgrade(), cx))); let mut inlay_hints_enabled = editor.read(cx).inlay_hints_enabled(); let mut supports_inlay_hints = editor.read(cx).supports_inlay_hints(cx); self._inlay_hints_enabled_subscription = diff --git a/crates/zed/src/zed/quick_action_bar/repl_menu.rs b/crates/zed/src/zed/quick_action_bar/repl_menu.rs index 3498bc4526..5032c5e307 100644 --- a/crates/zed/src/zed/quick_action_bar/repl_menu.rs +++ b/crates/zed/src/zed/quick_action_bar/repl_menu.rs @@ -3,16 +3,14 @@ use std::time::Duration; use editor::Editor; use gpui::{percentage, Animation, AnimationExt, AnyElement, Transformation, View}; use gpui::{ElementId, WeakView}; -use picker::Picker; -use repl::components::OnSelect; +use project::WorktreeId; use repl::{ - components::{KernelPickerDelegate, KernelSelector}, - worktree_id_for_editor, ExecutionState, JupyterSettings, Kernel, KernelSpecification, + components::KernelSelector, ExecutionState, JupyterSettings, Kernel, KernelSpecification, KernelStatus, Session, SessionSupport, }; use ui::{ prelude::*, ButtonLike, ContextMenu, IconWithIndicator, Indicator, IntoElement, PopoverMenu, - PopoverMenuHandle, Tooltip, + Tooltip, }; use util::ResultExt; @@ -37,9 +35,13 @@ pub struct ReplMenu { } impl ReplMenu { - pub fn new(editor: WeakView, cx: &mut ViewContext) -> Self { + pub fn new( + work_tree_id: WorktreeId, + editor: WeakView, + cx: &mut ViewContext, + ) -> Self { Self { - kernel_menu: cx.new_view(|cx| KernelSelector::new(editor.clone(), cx)), + kernel_menu: cx.new_view(|cx| KernelSelector::new(work_tree_id, editor.clone(), cx)), active_editor: editor.clone(), } } @@ -279,7 +281,7 @@ impl ReplMenu { pub fn render_repl_launch_menu( &self, kernel_specification: KernelSpecification, - cx: &mut ViewContext, + _cx: &mut ViewContext, ) -> impl IntoElement { let tooltip: SharedString = SharedString::from(format!("Start REPL for {}", kernel_specification.name())); @@ -294,7 +296,7 @@ impl ReplMenu { ) } - pub fn render_repl_setup(&self, language: &str, cx: &mut ViewContext) -> AnyElement { + pub fn render_repl_setup(&self, language: &str, _cx: &mut ViewContext) -> AnyElement { let tooltip: SharedString = SharedString::from(format!("Setup Zed REPL for {}", language)); h_flex() .child(self.kernel_menu.clone())