From 16a40389b48b283c2d8e0349d4716d5d31ad8e46 Mon Sep 17 00:00:00 2001 From: Poldraunic Date: Thu, 21 Nov 2024 18:40:37 +0300 Subject: [PATCH] pane: Hide "Reveal In Project Panel" for files outside of projects --- crates/workspace/src/pane.rs | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/crates/workspace/src/pane.rs b/crates/workspace/src/pane.rs index 3a19f100248c84..c6f53a811efee1 100644 --- a/crates/workspace/src/pane.rs +++ b/crates/workspace/src/pane.rs @@ -2362,6 +2362,7 @@ impl Pane { .and_then(|item| item.project_path(cx)) .map(|project_path| project_path.path) .map_or(None, |path| if path.exists() { Some(path) } else { None }); + let has_relative_path = relative_path.is_some(); let entry_id = entry.to_proto(); menu = menu @@ -2390,21 +2391,23 @@ impl Pane { }) .map(pin_tab_entries) .separator() - .entry( - "Reveal In Project Panel", - Some(Box::new(RevealInProjectPanel { - entry_id: Some(entry_id), - })), - cx.handler_for(&pane, move |pane, cx| { - pane.project - .update(cx, |_, cx| { - cx.emit(project::Event::RevealInProjectPanel( - ProjectEntryId::from_proto(entry_id), - )) - }) - .ok(); - }), - ) + .when(has_relative_path, |menu| { + menu.entry( + "Reveal In Project Panel", + Some(Box::new(RevealInProjectPanel { + entry_id: Some(entry_id), + })), + cx.handler_for(&pane, move |pane, cx| { + pane.project + .update(cx, |_, cx| { + cx.emit(project::Event::RevealInProjectPanel( + ProjectEntryId::from_proto(entry_id), + )) + }) + .ok(); + }), + ) + }) .when_some(parent_abs_path, |menu, parent_abs_path| { menu.entry( "Open in Terminal",