Reveal in files instead of Finder (#13432)

francesco-gaglione and Mikayla Maki created

fixes: #12776 

Release Notes:

- Renamed `editor::RevealInFinder` to `editor::RevealInFileManager`

---------

Co-authored-by: Mikayla Maki <mikayla@zed.dev>

Change summary

assets/keymaps/default-linux.json         |  8 ++++----
assets/keymaps/default-macos.json         |  9 +++++----
assets/keymaps/vim.json                   |  2 +-
crates/editor/src/actions.rs              |  2 +-
crates/editor/src/editor.rs               |  2 +-
crates/editor/src/mouse_context_menu.rs   | 10 ++++++++--
crates/outline_panel/src/outline_panel.rs | 11 ++++++++---
crates/project_panel/src/project_panel.rs | 11 ++++++++---
docs/src/key-bindings.md                  |  4 ++--
9 files changed, 38 insertions(+), 21 deletions(-)

Detailed changes

assets/keymaps/default-linux.json 🔗

@@ -296,8 +296,8 @@
       "ctrl-shift-]": "editor::UnfoldLines",
       "ctrl-space": "editor::ShowCompletions",
       "ctrl-.": "editor::ToggleCodeActions",
-      "alt-ctrl-r": "editor::RevealInFinder",
-      "ctrl-k r": "editor::RevealInFinder",
+      "alt-ctrl-r": "editor::RevealInFileManager",
+      "ctrl-k r": "editor::RevealInFileManager",
       "ctrl-k p": "editor::CopyPath",
       "ctrl-\\": "pane::SplitRight",
       "ctrl-k v": "markdown::OpenPreviewToTheSide",
@@ -507,7 +507,7 @@
       "right": "outline_panel::ExpandSelectedEntry",
       "ctrl-alt-c": "outline_panel::CopyPath",
       "alt-ctrl-shift-c": "outline_panel::CopyRelativePath",
-      "alt-ctrl-r": "outline_panel::RevealInFinder",
+      "alt-ctrl-r": "outline_panel::RevealInFileManager",
       "space": "outline_panel::Open",
       "shift-down": "menu::SelectNext",
       "shift-up": "menu::SelectPrev"
@@ -534,7 +534,7 @@
       "delete": ["project_panel::Trash", { "skip_prompt": false }],
       "ctrl-backspace": ["project_panel::Delete", { "skip_prompt": false }],
       "ctrl-delete": ["project_panel::Delete", { "skip_prompt": false }],
-      "alt-ctrl-r": "project_panel::RevealInFinder",
+      "alt-ctrl-r": "project_panel::RevealInFileManager",
       "alt-shift-f": "project_panel::NewSearchInDirectory",
       "shift-down": "menu::SelectNext",
       "shift-up": "menu::SelectPrev",

assets/keymaps/default-macos.json 🔗

@@ -336,8 +336,8 @@
       "alt-cmd-]": "editor::UnfoldLines",
       "ctrl-space": "editor::ShowCompletions",
       "cmd-.": "editor::ToggleCodeActions",
-      "alt-cmd-r": "editor::RevealInFinder",
-      "cmd-k r": "editor::RevealInFinder",
+      "alt-cmd-r": "editor::RevealInFileManager",
+      "cmd-k r": "editor::RevealInFileManager",
       "cmd-k p": "editor::CopyPath",
       "cmd-\\": "pane::SplitRight",
       "cmd-k v": "markdown::OpenPreviewToTheSide",
@@ -528,7 +528,7 @@
       "right": "outline_panel::ExpandSelectedEntry",
       "cmd-alt-c": "outline_panel::CopyPath",
       "alt-cmd-shift-c": "outline_panel::CopyRelativePath",
-      "alt-cmd-r": "outline_panel::RevealInFinder",
+      "alt-cmd-r": "outline_panel::RevealInFileManager",
       "space": "outline_panel::Open",
       "shift-down": "menu::SelectNext",
       "shift-up": "menu::SelectPrev"
@@ -553,8 +553,9 @@
       "delete": ["project_panel::Trash", { "skip_prompt": false }],
       "cmd-backspace": ["project_panel::Trash", { "skip_prompt": true }],
       "cmd-delete": ["project_panel::Delete", { "skip_prompt": false }],
+      "alt-cmd-r": "project_panel::RevealInFileManager",
       "cmd-alt-backspace": ["project_panel::Delete", { "skip_prompt": false }],
-      "alt-cmd-r": "project_panel::RevealInFinder",
+
       "alt-shift-f": "project_panel::NewSearchInDirectory",
       "shift-down": "menu::SelectNext",
       "shift-up": "menu::SelectPrev",

assets/keymaps/vim.json 🔗

@@ -504,7 +504,7 @@
       "t": "project_panel::OpenPermanent",
       "v": "project_panel::OpenPermanent",
       "p": "project_panel::Open",
-      "x": "project_panel::RevealInFinder",
+      "x": "project_panel::RevealInFileManager",
       "shift-g": "menu::SelectLast",
       "g g": "menu::SelectFirst",
       "-": "project_panel::SelectParent"

crates/editor/src/actions.rs 🔗

@@ -258,7 +258,7 @@ gpui::actions!(
         RedoSelection,
         Rename,
         RestartLanguageServer,
-        RevealInFinder,
+        RevealInFileManager,
         ReverseLines,
         RevertSelectedHunks,
         ScrollCursorBottom,

crates/editor/src/editor.rs 🔗

@@ -10333,7 +10333,7 @@ impl Editor {
         cx.notify();
     }
 
-    pub fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext<Self>) {
+    pub fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext<Self>) {
         if let Some(buffer) = self.buffer().read(cx).as_singleton() {
             if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {
                 cx.reveal_path(&file.abs_path(cx));

crates/editor/src/mouse_context_menu.rs 🔗

@@ -3,9 +3,10 @@ use std::ops::Range;
 use crate::{
     selections_collection::SelectionsCollection, Copy, CopyPermalinkToLine, Cut, DisplayPoint,
     DisplaySnapshot, Editor, EditorMode, FindAllReferences, GoToDefinition, GoToImplementation,
-    GoToTypeDefinition, Paste, Rename, RevealInFinder, SelectMode, ToDisplayPoint,
+    GoToTypeDefinition, Paste, Rename, RevealInFileManager, SelectMode, ToDisplayPoint,
     ToggleCodeActions,
 };
+use gpui::prelude::FluentBuilder;
 use gpui::{DismissEvent, Pixels, Point, Subscription, View, ViewContext};
 use workspace::OpenInTerminal;
 
@@ -113,7 +114,12 @@ pub fn deploy_context_menu(
                 .action("Copy", Box::new(Copy))
                 .action("Paste", Box::new(Paste))
                 .separator()
-                .action("Reveal in Finder", Box::new(RevealInFinder))
+                .when(cfg!(target_os = "macos"), |builder| {
+                    builder.action("Reveal in Finder", Box::new(RevealInFileManager))
+                })
+                .when(cfg!(not(target_os = "macos")), |builder| {
+                    builder.action("Reveal in File Manager", Box::new(RevealInFileManager))
+                })
                 .action("Open in Terminal", Box::new(OpenInTerminal))
                 .action("Copy Permalink", Box::new(CopyPermalinkToLine));
             match focus {

crates/outline_panel/src/outline_panel.rs 🔗

@@ -57,7 +57,7 @@ actions!(
         CollapseAllEntries,
         CopyPath,
         CopyRelativePath,
-        RevealInFinder,
+        RevealInFileManager,
         Open,
         ToggleFocus,
         UnfoldDirectory,
@@ -796,7 +796,12 @@ impl OutlinePanel {
 
         let context_menu = ContextMenu::build(cx, |menu, _| {
             menu.context(self.focus_handle.clone())
-                .action("Reveal in Finder", Box::new(RevealInFinder))
+                .when(cfg!(target_os = "macos"), |menu| {
+                    menu.action("Reveal in Finder", Box::new(RevealInFileManager))
+                })
+                .when(cfg!(not(target_os = "macos")), |menu| {
+                    menu.action("Reveal in File Manager", Box::new(RevealInFileManager))
+                })
                 .action("Open in Terminal", Box::new(OpenInTerminal))
                 .when(is_unfoldable, |menu| {
                     menu.action("Unfold Directory", Box::new(UnfoldDirectory))
@@ -1079,7 +1084,7 @@ impl OutlinePanel {
         }
     }
 
-    fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext<Self>) {
+    fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext<Self>) {
         if let Some(abs_path) = self
             .selected_entry
             .as_ref()

crates/project_panel/src/project_panel.rs 🔗

@@ -137,7 +137,7 @@ actions!(
         CopyPath,
         CopyRelativePath,
         Duplicate,
-        RevealInFinder,
+        RevealInFileManager,
         Cut,
         Paste,
         Rename,
@@ -477,7 +477,12 @@ impl ProjectPanel {
                         menu.action("New File", Box::new(NewFile))
                             .action("New Folder", Box::new(NewDirectory))
                             .separator()
-                            .action("Reveal in Finder", Box::new(RevealInFinder))
+                            .when(cfg!(target_os = "macos"), |menu| {
+                                menu.action("Reveal in Finder", Box::new(RevealInFileManager))
+                            })
+                            .when(cfg!(not(target_os = "macos")), |menu| {
+                                menu.action("Reveal in File Manager", Box::new(RevealInFileManager))
+                            })
                             .action("Open in Terminal", Box::new(OpenInTerminal))
                             .when(is_dir, |menu| {
                                 menu.separator()
@@ -1353,7 +1358,7 @@ impl ProjectPanel {
         }
     }
 
-    fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext<Self>) {
+    fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext<Self>) {
         if let Some((worktree, entry)) = self.selected_entry(cx) {
             cx.reveal_path(&worktree.abs_path().join(&entry.path));
         }

docs/src/key-bindings.md 🔗

@@ -267,7 +267,7 @@ See the [tasks documentation](/docs/tasks#custom-keybindings-for-tasks) for more
 | Redo                             | Editor     | `⌘ + Shift + Z`                 |
 | Redo selection                   | Editor     | `⌘ + Shift + U`                 |
 | Rename                           | Editor     | `F2`                            |
-| Reveal in finder                 | Editor     | `Alt + ⌘ + R`                   |
+| Reveal in File Manager           | Editor     | `Alt + ⌘ + R`                   |
 | Revert selected hunks            | Editor     | `⌘ + Alt + Z`                   |
 | Select all                       | Editor     | `⌘ + A`                         |
 | Select all matches               | Editor     | `⌘ + Shift + L`                 |
@@ -483,7 +483,7 @@ See the [tasks documentation](/docs/tasks#custom-keybindings-for-tasks) for more
 | Paste                   | Project Panel | `⌘ + V`               |
 | Rename                  | Project Panel | `Enter`               |
 | Rename                  | Project Panel | `F2`                  |
-| Reveal in finder        | Project Panel | `Alt + ⌘ + R`         |
+| Reveal in File Manager  | Project Panel | `Alt + ⌘ + R`         |
 
 #### Project Search Bar