From 2dd486733b2998e60a49dd06487038d566f40148 Mon Sep 17 00:00:00 2001 From: francesco-gaglione <94604837+francesco-gaglione@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:54:14 +0200 Subject: [PATCH] Reveal in files instead of Finder (#13432) fixes: #12776 Release Notes: - Renamed `editor::RevealInFinder` to `editor::RevealInFileManager` --------- Co-authored-by: Mikayla Maki --- 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(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index e060363a3281fab449cf0a2d33b6ff2238ff1c91..560ea88ab71e0b79c18e40e70da01cf315074d5a 100644 --- a/assets/keymaps/default-linux.json +++ b/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", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index b764ac09866eb9bb8dd2b74aa28fb1376b2f418f..9f5c834501d8ad3844002959c8cfb865ca5917f9 100644 --- a/assets/keymaps/default-macos.json +++ b/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", diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 0e98636e4164a2eba8ae134555f328d528ed541f..87ae91925a85450c4b0d72f8f036971825892bb4 100644 --- a/assets/keymaps/vim.json +++ b/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" diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs index 293d9da7199ccaedcaff0fe903367fe40523e16f..d0d7d912ee5ef00db9e9f21ace446d12a9717035 100644 --- a/crates/editor/src/actions.rs +++ b/crates/editor/src/actions.rs @@ -258,7 +258,7 @@ gpui::actions!( RedoSelection, Rename, RestartLanguageServer, - RevealInFinder, + RevealInFileManager, ReverseLines, RevertSelectedHunks, ScrollCursorBottom, diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 4f3eb7d25759f12b50a3012f434d1415bec4af90..a02891e6223e2507590bdae170d08f6412533981 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -10333,7 +10333,7 @@ impl Editor { cx.notify(); } - pub fn reveal_in_finder(&mut self, _: &RevealInFinder, cx: &mut ViewContext) { + pub fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext) { 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)); diff --git a/crates/editor/src/mouse_context_menu.rs b/crates/editor/src/mouse_context_menu.rs index a9449762f8d1afd77e30153e3ce5ad905f0f6275..56645ee25520cee68247b5c56db14584d0226d8a 100644 --- a/crates/editor/src/mouse_context_menu.rs +++ b/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 { diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 839c965840743ebd6f96d70ef6c9ed3ea929d06e..acda4ee668723a426a252d8fc9dbc920728ab838 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/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) { + fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext) { if let Some(abs_path) = self .selected_entry .as_ref() diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 0751b926cf1ca19e2d4d0cf10781f658a621c54a..ab0a30b2d7ea4a088450717e4095659794acb022 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/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) { + fn reveal_in_finder(&mut self, _: &RevealInFileManager, cx: &mut ViewContext) { if let Some((worktree, entry)) = self.selected_entry(cx) { cx.reveal_path(&worktree.abs_path().join(&entry.path)); } diff --git a/docs/src/key-bindings.md b/docs/src/key-bindings.md index fcec763734c2409c7bcb3095416ec7e9534add8f..aeff577c391f3bbb0015a39592cda2cbbc2194a0 100644 --- a/docs/src/key-bindings.md +++ b/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