Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
project_panel: Open file in editor on paste action when single entry (#25555)
smit796e87ecbc3d
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rsindex fd5c230995c..1cb66ea3a39 100644--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@ -2108,12 +2108,12 @@ impl ProjectPanel {match task {PasteTask::Rename(task) => {if let Some(CreatedEntry::Included(entry)) = task.await.log_err() {- last_succeed = Some(entry.id);+ last_succeed = Some(entry);}}PasteTask::Copy(task) => {if let Some(Some(entry)) = task.await.log_err() {- last_succeed = Some(entry.id);+ last_succeed = Some(entry);if need_delete {need_delete_ids.push(entry_id);}@@ -2133,17 +2133,31 @@ impl ProjectPanel {.await?;}// update selection- if let Some(entry_id) = last_succeed {+ if let Some(entry) = last_succeed {project_panel.update_in(&mut cx, |project_panel, window, cx| {project_panel.selection = Some(SelectedEntry {worktree_id,- entry_id,+ entry_id: entry.id,});- // if only one entry was pasted and it was disambiguated, open the rename editor- if item_count == 1 && disambiguation_range.is_some() {- project_panel.rename_impl(disambiguation_range, window, cx);+ if item_count == 1 {+ // open entry if not dir, and only focus if rename is not pending+ if !entry.is_dir() {+ project_panel.open_entry(+ entry.id,+ disambiguation_range.is_none(),+ false,+ cx,+ );+ }++ // if only one entry was pasted and it was disambiguated, open the rename editor+ if disambiguation_range.is_some() {+ cx.defer_in(window, |this, window, cx| {+ this.rename_impl(disambiguation_range, window, cx);+ });+ }}}).ok();@@ -5877,7 +5891,7 @@ mod tests {//"v root1"," one.txt",- " [EDITOR: 'one copy.txt'] <== selected",+ " [EDITOR: 'one copy.txt'] <== selected <== marked"," one.two.txt",]);@@ -5905,7 +5919,7 @@ mod tests {"v root1"," one.txt"," one copy.txt",- " [EDITOR: 'one copy 1.txt'] <== selected",+ " [EDITOR: 'one copy 1.txt'] <== selected <== marked"," one.two.txt",]);@@ -5978,7 +5992,7 @@ mod tests {" > b"," four.txt"," one.txt",- " three.txt <== selected",+ " three.txt <== selected <== marked"," two.txt",]);@@ -6006,7 +6020,7 @@ mod tests {" > b"," four.txt"," one.txt",- " three.txt",+ " three.txt <== marked"," two.txt",]);@@ -6076,7 +6090,7 @@ mod tests {" > b"," four.txt"," one.txt",- " three.txt <== selected",+ " three.txt <== selected <== marked"," two.txt",]);@@ -6106,7 +6120,7 @@ mod tests {" four.txt"," one.txt"," three.txt",- " [EDITOR: 'three copy.txt'] <== selected",+ " [EDITOR: 'three copy.txt'] <== selected <== marked"," two.txt",]);