Remove OpenProjectEntryInPane internal action

This commit is contained in:
Antonio Scandurra 2023-04-27 14:51:02 +02:00
parent b6437d6d9e
commit 20e38d2def
2 changed files with 19 additions and 35 deletions

View File

@ -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<V: View>(
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);
}
});
}
}
});
}
}
}
}

View File

@ -164,12 +164,6 @@ pub struct SplitWithProjectEntry {
project_entry: ProjectEntryId,
}
#[derive(Clone, PartialEq)]
pub struct OpenProjectEntryInPane {
pane: WeakViewHandle<Pane>,
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<AppState>, 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)