Introduce reveal_in_finder function

And use this function in a new Reveal in Finder option of the project panel context menu.

Co-Authored-By: Mikayla Maki <mikayla.c.maki@gmail.com>
This commit is contained in:
Petros Amoiridis 2023-02-10 21:11:05 +02:00
parent 7de04abdcb
commit a789476c95
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

View file

@ -119,6 +119,7 @@ actions!(
AddFile,
Copy,
CopyPath,
RevealInFinder,
Cut,
Paste,
Delete,
@ -147,6 +148,7 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(ProjectPanel::cancel);
cx.add_action(ProjectPanel::copy);
cx.add_action(ProjectPanel::copy_path);
cx.add_action(ProjectPanel::reveal_in_finder);
cx.add_action(ProjectPanel::cut);
cx.add_action(
|this: &mut ProjectPanel, action: &Paste, cx: &mut ViewContext<ProjectPanel>| {
@ -305,6 +307,7 @@ impl ProjectPanel {
}
menu_entries.push(ContextMenuItem::item("New File", AddFile));
menu_entries.push(ContextMenuItem::item("New Folder", AddDirectory));
menu_entries.push(ContextMenuItem::item("Reveal in Finder", RevealInFinder));
menu_entries.push(ContextMenuItem::Separator);
menu_entries.push(ContextMenuItem::item("Copy", Copy));
menu_entries.push(ContextMenuItem::item("Copy Path", CopyPath));
@ -787,6 +790,12 @@ impl ProjectPanel {
}
}
fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext<Self>) {
if let Some((_worktree, entry)) = self.selected_entry(cx) {
util::reveal_in_finder(&entry.path);
}
}
fn move_entry(
&mut self,
&MoveProjectEntry {