Skip to content

Commit

Permalink
pane: Hide "Reveal In Project Panel" for files outside of projects
Browse files Browse the repository at this point in the history
  • Loading branch information
Poldraunic committed Jan 19, 2025
1 parent a774330 commit 16a4038
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions crates/workspace/src/pane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 16a4038

Please sign in to comment.