Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
:lipstick:
Antonio Scandurra6cbc1dcd873c
diff --git a/crates/workspace/src/dock/toggle_dock_button.rs b/crates/workspace/src/dock/toggle_dock_button.rsindex babd08298a3..bf851839383 100644--- a/crates/workspace/src/dock/toggle_dock_button.rs+++ b/crates/workspace/src/dock/toggle_dock_button.rs@@ -67,9 +67,17 @@ impl View for ToggleDockButton {}}).with_cursor_style(CursorStyle::PointingHand)- .on_up(MouseButton::Left, move |event, _, cx| {+ .on_up(MouseButton::Left, move |event, this, cx| {let drop_index = dock_pane.read(cx).items_len() + 1;- handle_dropped_item(event, &dock_pane.downgrade(), drop_index, false, None, cx);+ handle_dropped_item(+ event,+ this.workspace.clone(),+ &dock_pane.downgrade(),+ drop_index,+ false,+ None,+ cx,+ );});if dock_position.is_visible() {diff --git a/crates/workspace/src/pane/dragged_item_receiver.rs b/crates/workspace/src/pane/dragged_item_receiver.rsindex 63eac1ccb9c..3cd26697bc5 100644--- a/crates/workspace/src/pane/dragged_item_receiver.rs+++ b/crates/workspace/src/pane/dragged_item_receiver.rs@@ -69,9 +69,18 @@ where}))}).on_up(MouseButton::Left, {- move |event, _, cx| {+ move |event, pane, cx| {+ let workspace = pane.workspace.clone();let pane = cx.weak_handle();- handle_dropped_item(event, &pane, drop_index, allow_same_pane, split_margin, cx);+ handle_dropped_item(+ event,+ workspace,+ &pane,+ drop_index,+ allow_same_pane,+ split_margin,+ cx,+ );cx.notify();}})@@ -94,6 +103,7 @@ wherepub fn handle_dropped_item<V: View>(event: MouseUp,+ workspace: WeakViewHandle<Workspace>,pane: &WeakViewHandle<Pane>,index: usize,allow_same_pane: bool,@@ -141,12 +151,14 @@ pub fn handle_dropped_item<V: View>(if pane != &from || allow_same_pane {let pane = pane.clone();cx.window_context().defer(move |cx| {- if let Some((from, to)) = from.upgrade(cx).zip(pane.upgrade(cx)) {- if let Some(workspace) = from.read(cx).workspace.upgrade(cx) {- workspace.update(cx, |workspace, cx| {- Pane::move_item(workspace, from, to, item_id, index, cx);- })- }+ if let Some(((workspace, from), to)) = workspace+ .upgrade(cx)+ .zip(from.upgrade(cx))+ .zip(pane.upgrade(cx))+ {+ workspace.update(cx, |workspace, cx| {+ Pane::move_item(workspace, from, to, item_id, index, cx);+ })}});} else {@@ -156,18 +168,16 @@ pub fn handle_dropped_item<V: View>(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);- }- });- }+ if let Some(workspace) = 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), true, cx)+ .detach_and_log_err(cx);+ }+ });}});}