Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Remove `SplitWithItem` internal action
Antonio Scandurra272039a85886
diff --git a/crates/workspace/src/pane/dragged_item_receiver.rs b/crates/workspace/src/pane/dragged_item_receiver.rsindex 3cd26697bc5..bfc9e57cb09 100644--- a/crates/workspace/src/pane/dragged_item_receiver.rs+++ b/crates/workspace/src/pane/dragged_item_receiver.rs@@ -10,7 +10,7 @@ use gpui::{use project::ProjectEntryId;use settings::Settings;-use crate::{Pane, SplitDirection, SplitWithItem, SplitWithProjectEntry, Workspace};+use crate::{Pane, SplitDirection, SplitWithProjectEntry, Workspace};use super::DraggedItem;@@ -133,12 +133,21 @@ pub fn handle_dropped_item<V: View>({let pane_to_split = pane.clone();match action {- Action::Move(from, item_id_to_move) => cx.dispatch_action(SplitWithItem {- from,- item_id_to_move,- pane_to_split,- split_direction,- }),+ Action::Move(from, item_id_to_move) => {+ cx.window_context().defer(move |cx| {+ if let Some(workspace) = workspace.upgrade(cx) {+ workspace.update(cx, |workspace, cx| {+ workspace.split_pane_with_item(+ pane_to_split,+ split_direction,+ from,+ item_id_to_move,+ cx,+ );+ })+ }+ });+ }Action::Open(project_entry) => cx.dispatch_action(SplitWithProjectEntry {pane_to_split,split_direction,diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex cc8ef5781ae..ed44fdb1c26 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -134,14 +134,6 @@ pub struct OpenPaths {#[derive(Clone, Deserialize, PartialEq)]pub struct ActivatePane(pub usize);-#[derive(Clone, PartialEq)]-pub struct SplitWithItem {- pane_to_split: WeakViewHandle<Pane>,- split_direction: SplitDirection,- from: WeakViewHandle<Pane>,- item_id_to_move: usize,-}-#[derive(Clone, PartialEq)]pub struct SplitWithProjectEntry {pane_to_split: WeakViewHandle<Pane>,@@ -201,7 +193,7 @@ impl Clone for Toast {pub type WorkspaceId = i64;-impl_internal_actions!(workspace, [SplitWithItem, SplitWithProjectEntry,]);+impl_internal_actions!(workspace, [SplitWithProjectEntry]);impl_actions!(workspace, [ActivatePane]);pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {@@ -307,7 +299,6 @@ pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {});cx.add_action(Workspace::activate_pane_at_index);- cx.add_action(Workspace::split_pane_with_item);cx.add_async_action(Workspace::split_pane_with_project_entry);cx.add_action(|_: &mut Workspace, _: &install_cli::Install, cx| {@@ -1735,25 +1726,25 @@ impl Workspace {maybe_pane_handle}- pub fn split_pane_with_item(&mut self, action: &SplitWithItem, cx: &mut ViewContext<Self>) {- let Some(pane_to_split) = action.pane_to_split.upgrade(cx) else { return; };- let Some(from) = action.from.upgrade(cx) else { return; };+ pub fn split_pane_with_item(+ &mut self,+ pane_to_split: WeakViewHandle<Pane>,+ split_direction: SplitDirection,+ from: WeakViewHandle<Pane>,+ item_id_to_move: usize,+ cx: &mut ViewContext<Self>,+ ) {+ let Some(pane_to_split) = pane_to_split.upgrade(cx) else { return; };+ let Some(from) = from.upgrade(cx) else { return; };if &pane_to_split == self.dock_pane() {warn!("Can't split dock pane.");return;}let new_pane = self.add_pane(cx);- Pane::move_item(- self,- from.clone(),- new_pane.clone(),- action.item_id_to_move,- 0,- cx,- );+ Pane::move_item(self, from.clone(), new_pane.clone(), item_id_to_move, 0, cx);self.center- .split(&pane_to_split, &new_pane, action.split_direction)+ .split(&pane_to_split, &new_pane, split_direction).unwrap();cx.notify();}