Select right-clicked entry before deploying context menu

Antonio Scandurra and Nathan Sobo created

Co-Authored-By: Nathan Sobo <nathan@zed.dev>

Change summary

crates/project_panel/src/project_panel.rs | 10 ++++++++++
1 file changed, 10 insertions(+)

Detailed changes

crates/project_panel/src/project_panel.rs 🔗

@@ -207,6 +207,15 @@ impl ProjectPanel {
     }
 
     fn deploy_context_menu(&mut self, action: &DeployContextMenu, cx: &mut ViewContext<Self>) {
+        if let Some(entry_id) = action.entry_id {
+            if let Some(worktree_id) = self.project.read(cx).worktree_id_for_entry(entry_id, cx) {
+                self.selection = Some(Selection {
+                    worktree_id,
+                    entry_id,
+                });
+            }
+        }
+
         self.context_menu.update(cx, |menu, cx| {
             menu.show(
                 action.position,
@@ -232,6 +241,7 @@ impl ProjectPanel {
                 cx,
             );
         });
+
         cx.notify();
     }