From 35ce34c6765963c4bd7dd0ae9b5d43e1f2651dcb Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 8 Jan 2024 22:12:40 +0200 Subject: [PATCH] Show context menu on project panel empty space right click --- crates/project_panel/src/project_panel.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index a5fb8671f7..ee016f399e 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1515,6 +1515,16 @@ impl Render for ProjectPanel { el.on_action(cx.listener(Self::reveal_in_finder)) .on_action(cx.listener(Self::open_in_terminal)) }) + .on_mouse_down( + MouseButton::Right, + cx.listener(move |this, event: &MouseDownEvent, cx| { + // When deploying the context menu anywhere below the last project entry, + // act as if the user clicked the root of the last worktree. + if let Some(entry_id) = this.last_worktree_root_id { + this.deploy_context_menu(event.position, entry_id, cx); + } + }), + ) .track_focus(&self.focus_handle) .child( uniform_list(