diff --git a/crates/workspace/src/pane/dragged_item_receiver.rs b/crates/workspace/src/pane/dragged_item_receiver.rs index bde6d4b371102fea49510c458b8b1175430a6d37..63eac1ccb9c89d28d59917e4b286dbfbb572166f 100644 --- a/crates/workspace/src/pane/dragged_item_receiver.rs +++ b/crates/workspace/src/pane/dragged_item_receiver.rs @@ -10,9 +10,7 @@ use gpui::{ use project::ProjectEntryId; use settings::Settings; -use crate::{ - OpenProjectEntryInPane, Pane, SplitDirection, SplitWithItem, SplitWithProjectEntry, Workspace, -}; +use crate::{Pane, SplitDirection, SplitWithItem, SplitWithProjectEntry, Workspace}; use super::DraggedItem; @@ -155,10 +153,24 @@ pub fn handle_dropped_item( cx.propagate_event(); } } - Action::Open(project_entry) => cx.dispatch_action(OpenProjectEntryInPane { - pane: pane.clone(), - project_entry, - }), + Action::Open(project_entry) => { + let pane = pane.clone(); + cx.window_context().defer(move |cx| { + if let Some(pane) = pane.upgrade(cx) { + if let Some(workspace) = pane.read(cx).workspace.upgrade(cx) { + workspace.update(cx, |workspace, cx| { + if let Some(path) = + workspace.project.read(cx).path_for_entry(project_entry, cx) + { + workspace + .open_path(path, Some(pane.downgrade()), true, cx) + .detach_and_log_err(cx); + } + }); + } + } + }); + } } } } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 420d5adc63ca9ff105a3d86270daedcbf392f682..2d70faed0674f55015cb25e08b77cc498dd20445 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -164,12 +164,6 @@ pub struct SplitWithProjectEntry { project_entry: ProjectEntryId, } -#[derive(Clone, PartialEq)] -pub struct OpenProjectEntryInPane { - pane: WeakViewHandle, - project_entry: ProjectEntryId, -} - pub struct Toast { id: usize, msg: Cow<'static, str>, @@ -232,7 +226,6 @@ impl_internal_actions!( RemoveWorktreeFromProject, SplitWithItem, SplitWithProjectEntry, - OpenProjectEntryInPane, ] ); impl_actions!(workspace, [ActivatePane]); @@ -374,27 +367,6 @@ pub fn init(app_state: Arc, cx: &mut AppContext) { cx.add_action(Workspace::split_pane_with_item); cx.add_async_action(Workspace::split_pane_with_project_entry); - cx.add_async_action( - |workspace: &mut Workspace, - OpenProjectEntryInPane { - pane, - project_entry, - }: &_, - cx| { - workspace - .project - .read(cx) - .path_for_entry(*project_entry, cx) - .map(|path| { - let task = workspace.open_path(path, Some(pane.clone()), true, cx); - cx.foreground().spawn(async move { - task.await?; - Ok(()) - }) - }) - }, - ); - cx.add_action(|_: &mut Workspace, _: &install_cli::Install, cx| { cx.spawn(|workspace, mut cx| async move { let err = install_cli::install_cli(&cx)