Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Fix pane deduplication for unsaved buffers that have no path (#30834)
Michael Sloan784d51c40fb7
diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rsindex 41cf81d897e..6b5ff95f129 100644--- a/crates/workspace/src/pane.rs+++ b/crates/workspace/src/pane.rs@@ -791,6 +791,7 @@ impl Pane {pub(crate) fn open_item(&mut self,project_entry_id: Option<ProjectEntryId>,+ project_path: ProjectPath,focus_item: bool,allow_preview: bool,activate: bool,@@ -810,6 +811,14 @@ impl Pane {break;}}+ } else {+ for (index, item) in self.items.iter().enumerate() {+ if item.is_singleton(cx) && item.project_path(cx).as_ref() == Some(&project_path) {+ let item = item.boxed_clone();+ existing_item = Some((index, item));+ break;+ }+ }}if let Some((index, existing_item)) = existing_item {// If the item is already open, and the item is a preview item@@ -2914,12 +2923,12 @@ impl Pane {self.workspace.update(cx, |_, cx| {cx.defer_in(window, move |workspace, window, cx| {- if let Some(path) = workspace+ if let Some(project_path) = workspace.project().read(cx).path_for_entry(project_entry_id, cx){- let load_path_task = workspace.load_path(path, window, cx);+ let load_path_task = workspace.load_path(project_path.clone(), window, cx);cx.spawn_in(window, async move |workspace, cx| {if let Some((project_entry_id, build_item)) =load_path_task.await.notify_async_err(cx)@@ -2937,6 +2946,7 @@ impl Pane {let new_item_handle = to_pane.update(cx, |pane, cx| {pane.open_item(project_entry_id,+ project_path,true,false,true,diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rsindex e84a7cdd6cb..b442560be65 100644--- a/crates/workspace/src/workspace.rs+++ b/crates/workspace/src/workspace.rs@@ -1707,6 +1707,7 @@ impl Workspace {pane.update_in(cx, |pane, window, cx| {let item = pane.open_item(project_entry_id,+ project_path,true,entry.is_preview,true,@@ -3091,12 +3092,14 @@ impl Workspace {})});- let task = self.load_path(path.into(), window, cx);+ let project_path = path.into();+ let task = self.load_path(project_path.clone(), window, cx);window.spawn(cx, async move |cx| {let (project_entry_id, build_item) = task.await?;let result = pane.update_in(cx, |pane, window, cx| {let result = pane.open_item(project_entry_id,+ project_path,focus_item,allow_preview,activate,@@ -3142,7 +3145,8 @@ impl Workspace {}}- let task = self.load_path(path.into(), window, cx);+ let project_path = path.into();+ let task = self.load_path(project_path.clone(), window, cx);cx.spawn_in(window, async move |this, cx| {let (project_entry_id, build_item) = task.await?;this.update_in(cx, move |this, window, cx| -> Option<_> {@@ -3156,6 +3160,7 @@ impl Workspace {new_pane.update(cx, |new_pane, cx| {Some(new_pane.open_item(project_entry_id,+ project_path,true,allow_preview,true,