Detailed changes
@@ -699,8 +699,6 @@ actions!(
Rename,
/// Restarts the language server for the current file.
RestartLanguageServer,
- /// Reveals the current file in the system file manager.
- RevealInFileManager,
/// Reverses the order of selected lines.
ReverseLines,
/// Reloads the file from disk.
@@ -221,6 +221,7 @@ use workspace::{
notifications::{DetachAndPromptErr, NotificationId, NotifyTaskExt},
searchable::SearchEvent,
};
+pub use zed_actions::editor::RevealInFileManager;
use zed_actions::editor::{MoveDown, MoveUp};
use crate::{
@@ -286,13 +286,7 @@ pub fn deploy_context_menu(
.separator()
.action_disabled_when(
!has_reveal_target,
- if cfg!(target_os = "macos") {
- "Reveal in Finder"
- } else if cfg!(target_os = "windows") {
- "Reveal in File Explorer"
- } else {
- "Reveal in File Manager"
- },
+ ui::utils::reveal_in_file_manager_label(false),
Box::new(RevealInFileManager),
)
.when(is_markdown, |builder| {
@@ -1490,13 +1490,7 @@ impl OutlinePanel {
let context_menu = ContextMenu::build(window, cx, |menu, _, _| {
menu.context(self.focus_handle.clone())
.action(
- if cfg!(target_os = "macos") {
- "Reveal in Finder"
- } else if cfg!(target_os = "windows") {
- "Reveal in File Explorer"
- } else {
- "Reveal in File Manager"
- },
+ ui::utils::reveal_in_file_manager_label(false),
Box::new(RevealInFileManager),
)
.action("Open in Terminal", Box::new(OpenInTerminal))
@@ -1201,13 +1201,7 @@ impl ProjectPanel {
.separator()
.when(is_local, |menu| {
menu.action(
- if cfg!(target_os = "macos") && !is_remote {
- "Reveal in Finder"
- } else if cfg!(target_os = "windows") && !is_remote {
- "Reveal in File Explorer"
- } else {
- "Reveal in File Manager"
- },
+ ui::utils::reveal_in_file_manager_label(is_remote),
Box::new(RevealInFileManager),
)
})
@@ -23,3 +23,14 @@ pub use with_rem_size::*;
pub fn is_light(cx: &mut App) -> bool {
cx.theme().appearance.is_light()
}
+
+/// Returns the platform-appropriate label for the "reveal in file manager" action.
+pub fn reveal_in_file_manager_label(is_remote: bool) -> &'static str {
+ if cfg!(target_os = "macos") && !is_remote {
+ "Reveal in Finder"
+ } else if cfg!(target_os = "windows") && !is_remote {
+ "Reveal in File Explorer"
+ } else {
+ "Reveal in File Manager"
+ }
+}
@@ -3192,6 +3192,7 @@ impl Pane {
});
let entry_abs_path = pane.read(cx).entry_abs_path(entry, cx);
+ let reveal_path = entry_abs_path.clone();
let parent_abs_path = entry_abs_path
.as_deref()
.and_then(|abs_path| Some(abs_path.parent()?.to_path_buf()));
@@ -3201,6 +3202,15 @@ impl Pane {
let visible_in_project_panel = relative_path.is_some()
&& worktree.is_some_and(|worktree| worktree.read(cx).is_visible());
+ let is_local = pane.read(cx).project.upgrade().is_some_and(|project| {
+ let project = project.read(cx);
+ project.is_local() || project.is_via_wsl_with_host_interop(cx)
+ });
+ let is_remote = pane
+ .read(cx)
+ .project
+ .upgrade()
+ .is_some_and(|project| project.read(cx).is_remote());
let entry_id = entry.to_proto();
@@ -3233,8 +3243,26 @@ impl Pane {
}),
)
})
+ .when(is_local, |menu| {
+ menu.when_some(reveal_path, |menu, reveal_path| {
+ menu.separator().entry(
+ ui::utils::reveal_in_file_manager_label(is_remote),
+ Some(Box::new(
+ zed_actions::editor::RevealInFileManager,
+ )),
+ window.handler_for(&pane, move |pane, _, cx| {
+ if let Some(project) = pane.project.upgrade() {
+ project.update(cx, |project, cx| {
+ project.reveal_path(&reveal_path, cx);
+ });
+ } else {
+ cx.reveal_path(&reveal_path);
+ }
+ }),
+ )
+ })
+ })
.map(pin_tab_entries)
- .separator()
.when(visible_in_project_panel, |menu| {
menu.entry(
"Reveal In Project Panel",
@@ -197,6 +197,8 @@ pub mod editor {
MoveUp,
/// Moves cursor down.
MoveDown,
+ /// Reveals the current file in the system file manager.
+ RevealInFileManager,
]
);
}