Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
workspace: Improve error handling when dropping a file that cannot be opened into the workspace pane (#15613)
Suhun Hanb67404323c34
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex c6d1241a4b5..08a85d486cb 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -3,6 +3,7 @@ use crate::{ClosePosition, Item, ItemHandle, ItemSettings, PreviewTabsSettings, TabContentParams,WeakItemHandle,},+ notifications::NotifyResultExt,toolbar::Toolbar,workspace_settings::{AutosaveSetting, TabBarSettings, WorkspaceSettings},CloseWindow, CopyPath, CopyRelativePath, NewFile, NewTerminal, OpenInTerminal, OpenTerminal,@@ -2109,13 +2110,32 @@ impl Pane {.read(cx).path_for_entry(project_entry_id, cx){- if let Some(split_direction) = split_direction {- to_pane = workspace.split_pane(to_pane, split_direction, cx);- }- workspace- .open_path(path, Some(to_pane.downgrade()), true, cx)- .detach_and_log_err(cx);- }+ let load_path_task = workspace.load_path(path, cx);+ cx.spawn(|workspace, mut cx| async move {+ if let Some((project_entry_id, build_item)) =+ load_path_task.await.notify_async_err(&mut cx)+ {+ workspace+ .update(&mut cx, |workspace, cx| {+ if let Some(split_direction) = split_direction {+ to_pane =+ workspace.split_pane(to_pane, split_direction, cx);+ }+ to_pane.update(cx, |pane, cx| {+ pane.open_item(+ project_entry_id,+ true,+ false,+ cx,+ build_item,+ )+ })+ })+ .log_err();+ }+ })+ .detach();+ };});}).log_err();@@ -2186,7 +2206,14 @@ impl Pane {}).ok(){- let _opened_items: Vec<_> = open_task.await;+ let opened_items: Vec<_> = open_task.await;+ _ = workspace.update(&mut cx, |workspace, cx| {+ for item in opened_items.into_iter().flatten() {+ if let Err(e) = item {+ workspace.show_error(&e, cx);+ }+ }+ });}}).detach();