From cde6680cf58f92512193eac17e109bde9fc11129 Mon Sep 17 00:00:00 2001 From: Poldraunic Date: Thu, 21 Nov 2024 18:36:24 +0300 Subject: [PATCH] pane: Add "Reveal In File Manager" action to context menu --- crates/workspace/src/pane.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index e3fe6c3f9ef005..2c3660adcf6cf4 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -144,6 +144,10 @@ pub struct RevealInProjectPanel { pub entry_id: Option, } +#[derive(Clone, PartialEq, Debug, Deserialize, Default)] +#[serde(rename_all = "camelCase")] +pub struct RevealInFileManager {} + #[derive(Default, PartialEq, Clone, Deserialize)] pub struct DeploySearch { #[serde(default)] @@ -161,6 +165,7 @@ impl_actions!( CloseInactiveItems, ActivateItem, RevealInProjectPanel, + RevealInFileManager, DeploySearch, ] ); @@ -2236,6 +2241,21 @@ impl Pane { }), ) }) + .when_some(parent_abs_path.clone(), |menu, parent_abs_path| { + let reveal_in_finder_label = if cfg!(target_os = "macos") { + "Reveal in Finder" + } else { + "Reveal in File Manager" + }; + + menu.entry( + reveal_in_finder_label, + Some(Box::new(RevealInFileManager {})), + cx.handler_for(&pane, move |_, cx| { + cx.reveal_path(&parent_abs_path); + }), + ) + }) .when_some(parent_abs_path, |menu, parent_abs_path| { menu.entry( "Open in Terminal",