From ac2402f24a0367d1a8e33731ec03fe744bc1b92d Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:07:08 +0200 Subject: [PATCH] Fix terminal drag and drop (cherry-pick #23827) (#23828) Cherry-picked Fix terminal drag and drop (#23827) Closes https://github.com/zed-industries/zed/discussions/23823 * Fixes terminal drag and drop not working after https://github.com/zed-industries/zed/pull/23256 * Fixes project panel items drag and drop not working after selection overhaul even earlier: now, all marked items are added to terminal on drag and drop Release Notes: - Fixed terminal drag and drop, including project panel items --------- Co-authored-by: Kirill Bulatov --- crates/terminal_view/src/terminal_panel.rs | 19 +++++++++++++++---- crates/terminal_view/src/terminal_view.rs | 1 - 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index b82136db9ec2431973c5bd0de2f8d8e70cf1888e..0498401332338a14c2e81ffc093be1f123384c6d 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -35,10 +35,10 @@ use workspace::{ item::SerializableItem, move_active_item, move_item, pane, ui::IconName, - ActivateNextPane, ActivatePane, ActivatePaneInDirection, ActivatePreviousPane, DraggedTab, - ItemId, MoveItemToPane, MoveItemToPaneInDirection, NewTerminal, Pane, PaneGroup, - SplitDirection, SplitDown, SplitLeft, SplitRight, SplitUp, SwapPaneInDirection, ToggleZoom, - Workspace, + ActivateNextPane, ActivatePane, ActivatePaneInDirection, ActivatePreviousPane, + DraggedSelection, DraggedTab, ItemId, MoveItemToPane, MoveItemToPaneInDirection, NewTerminal, + Pane, PaneGroup, SplitDirection, SplitDown, SplitLeft, SplitRight, SplitUp, + SwapPaneInDirection, ToggleZoom, Workspace, }; use anyhow::{anyhow, Context, Result}; @@ -1000,6 +1000,17 @@ pub fn new_terminal_pane( } } } + } else if let Some(selection) = dropped_item.downcast_ref::() { + let project = project.read(cx); + let paths_to_add = selection + .items() + .map(|selected_entry| selected_entry.entry_id) + .filter_map(|entry_id| project.path_for_entry(entry_id, cx)) + .filter_map(|project_path| project.absolute_path(&project_path, cx)) + .collect::>(); + if !paths_to_add.is_empty() { + add_paths_to_terminal(pane, &paths_to_add, cx); + } } else if let Some(&entry_id) = dropped_item.downcast_ref::() { if let Some(entry_path) = project .read(cx) diff --git a/crates/terminal_view/src/terminal_view.rs b/crates/terminal_view/src/terminal_view.rs index 8bd0fc97f7caaa3d46cba43574f6b7abdebcd52a..22fa0c145b5d6149cbebcf7c1e495d8f0056dd75 100644 --- a/crates/terminal_view/src/terminal_view.rs +++ b/crates/terminal_view/src/terminal_view.rs @@ -1094,7 +1094,6 @@ impl Render for TerminalView { let focused = self.focus_handle.is_focused(cx); div() - .occlude() .id("terminal-view") .size_full() .relative()