pane: Add "Reveal In File Manager" action to context menu

This commit is contained in:
Poldraunic 2024-11-21 18:36:24 +03:00
parent 19641d4c98
commit d2321fc966

View file

@ -144,6 +144,10 @@ pub struct RevealInProjectPanel {
pub entry_id: Option<u64>,
}
#[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,
]
);
@ -2258,6 +2263,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",