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
This commit is contained in:
Kirill Bulatov 2025-01-29 11:44:51 +02:00 committed by GitHub
parent d2d9f492b9
commit 46f45464be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 5 deletions

View file

@ -35,10 +35,10 @@ use workspace::{
item::SerializableItem, item::SerializableItem,
move_active_item, move_item, pane, move_active_item, move_item, pane,
ui::IconName, ui::IconName,
ActivateNextPane, ActivatePane, ActivatePaneInDirection, ActivatePreviousPane, DraggedTab, ActivateNextPane, ActivatePane, ActivatePaneInDirection, ActivatePreviousPane,
ItemId, MoveItemToPane, MoveItemToPaneInDirection, NewTerminal, Pane, PaneGroup, DraggedSelection, DraggedTab, ItemId, MoveItemToPane, MoveItemToPaneInDirection, NewTerminal,
SplitDirection, SplitDown, SplitLeft, SplitRight, SplitUp, SwapPaneInDirection, ToggleZoom, Pane, PaneGroup, SplitDirection, SplitDown, SplitLeft, SplitRight, SplitUp,
Workspace, SwapPaneInDirection, ToggleZoom, Workspace,
}; };
use anyhow::{anyhow, Context as _, Result}; use anyhow::{anyhow, Context as _, Result};
@ -1037,6 +1037,17 @@ pub fn new_terminal_pane(
} }
} }
} }
} else if let Some(selection) = dropped_item.downcast_ref::<DraggedSelection>() {
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::<Vec<_>>();
if !paths_to_add.is_empty() {
add_paths_to_terminal(pane, &paths_to_add, window, cx);
}
} else if let Some(&entry_id) = dropped_item.downcast_ref::<ProjectEntryId>() { } else if let Some(&entry_id) = dropped_item.downcast_ref::<ProjectEntryId>() {
if let Some(entry_path) = project if let Some(entry_path) = project
.read(cx) .read(cx)

View file

@ -1130,7 +1130,6 @@ impl Render for TerminalView {
let focused = self.focus_handle.is_focused(window); let focused = self.focus_handle.is_focused(window);
div() div()
.occlude()
.id("terminal-view") .id("terminal-view")
.size_full() .size_full()
.relative() .relative()