Skip to content

Commit 19641d4

Browse files
committed
pane: Hide "Reveal In Project Panel" action if file doesn't belong to a worktree
Building on the previous commit before we now also hide this action.
1 parent f5c89e7 commit 19641d4

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

crates/workspace/src/pane.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,6 +2214,7 @@ impl Pane {
22142214
.and_then(|item| item.project_path(cx))
22152215
.map(|project_path| project_path.path)
22162216
.map_or(None, |path| if path.exists() { Some(path) } else { None });
2217+
let has_relative_path = relative_path.is_some();
22172218

22182219
let entry_id = entry.to_proto();
22192220
menu = menu
@@ -2242,19 +2243,21 @@ impl Pane {
22422243
})
22432244
.map(pin_tab_entries)
22442245
.separator()
2245-
.entry(
2246-
"Reveal In Project Panel",
2247-
Some(Box::new(RevealInProjectPanel {
2248-
entry_id: Some(entry_id),
2249-
})),
2250-
cx.handler_for(&pane, move |pane, cx| {
2251-
pane.project.update(cx, |_, cx| {
2252-
cx.emit(project::Event::RevealInProjectPanel(
2253-
ProjectEntryId::from_proto(entry_id),
2254-
))
2255-
});
2256-
}),
2257-
)
2246+
.when(has_relative_path, |menu| {
2247+
menu.entry(
2248+
"Reveal In Project Panel",
2249+
Some(Box::new(RevealInProjectPanel {
2250+
entry_id: Some(entry_id),
2251+
})),
2252+
cx.handler_for(&pane, move |pane, cx| {
2253+
pane.project.update(cx, |_, cx| {
2254+
cx.emit(project::Event::RevealInProjectPanel(
2255+
ProjectEntryId::from_proto(entry_id),
2256+
))
2257+
});
2258+
}),
2259+
)
2260+
})
22582261
.when_some(parent_abs_path, |menu, parent_abs_path| {
22592262
menu.entry(
22602263
"Open in Terminal",

0 commit comments

Comments
 (0)