editor: Fix multi buffer header context menu not handling absolute paths (#36769)
Release Notes: - N/A
This commit is contained in:
parent
42ae3301d0
commit
72bd248544
1 changed files with 21 additions and 9 deletions
|
@ -74,6 +74,7 @@ use std::{
|
||||||
fmt::{self, Write},
|
fmt::{self, Write},
|
||||||
iter, mem,
|
iter, mem,
|
||||||
ops::{Deref, Range},
|
ops::{Deref, Range},
|
||||||
|
path::Path,
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, Instant},
|
time::{Duration, Instant},
|
||||||
|
@ -3693,7 +3694,12 @@ impl EditorElement {
|
||||||
})
|
})
|
||||||
.take(1),
|
.take(1),
|
||||||
)
|
)
|
||||||
.children(indicator)
|
.child(
|
||||||
|
h_flex()
|
||||||
|
.size(Pixels(12.0))
|
||||||
|
.justify_center()
|
||||||
|
.children(indicator),
|
||||||
|
)
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.cursor_pointer()
|
.cursor_pointer()
|
||||||
|
@ -3782,25 +3788,31 @@ impl EditorElement {
|
||||||
&& let Some(worktree) =
|
&& let Some(worktree) =
|
||||||
project.read(cx).worktree_for_id(file.worktree_id(cx), cx)
|
project.read(cx).worktree_for_id(file.worktree_id(cx), cx)
|
||||||
{
|
{
|
||||||
|
let worktree = worktree.read(cx);
|
||||||
let relative_path = file.path();
|
let relative_path = file.path();
|
||||||
let entry_for_path = worktree.read(cx).entry_for_path(relative_path);
|
let entry_for_path = worktree.entry_for_path(relative_path);
|
||||||
let abs_path = entry_for_path.and_then(|e| e.canonical_path.as_deref());
|
let abs_path = entry_for_path.map(|e| {
|
||||||
let has_relative_path =
|
e.canonical_path.as_deref().map_or_else(
|
||||||
worktree.read(cx).root_entry().is_some_and(Entry::is_dir);
|
|| worktree.abs_path().join(relative_path),
|
||||||
|
Path::to_path_buf,
|
||||||
|
)
|
||||||
|
});
|
||||||
|
let has_relative_path = worktree.root_entry().is_some_and(Entry::is_dir);
|
||||||
|
|
||||||
let parent_abs_path =
|
let parent_abs_path = abs_path
|
||||||
abs_path.and_then(|abs_path| Some(abs_path.parent()?.to_path_buf()));
|
.as_ref()
|
||||||
|
.and_then(|abs_path| Some(abs_path.parent()?.to_path_buf()));
|
||||||
let relative_path = has_relative_path
|
let relative_path = has_relative_path
|
||||||
.then_some(relative_path)
|
.then_some(relative_path)
|
||||||
.map(ToOwned::to_owned);
|
.map(ToOwned::to_owned);
|
||||||
|
|
||||||
let visible_in_project_panel =
|
let visible_in_project_panel =
|
||||||
relative_path.is_some() && worktree.read(cx).is_visible();
|
relative_path.is_some() && worktree.is_visible();
|
||||||
let reveal_in_project_panel = entry_for_path
|
let reveal_in_project_panel = entry_for_path
|
||||||
.filter(|_| visible_in_project_panel)
|
.filter(|_| visible_in_project_panel)
|
||||||
.map(|entry| entry.id);
|
.map(|entry| entry.id);
|
||||||
menu = menu
|
menu = menu
|
||||||
.when_some(abs_path.map(ToOwned::to_owned), |menu, abs_path| {
|
.when_some(abs_path, |menu, abs_path| {
|
||||||
menu.entry(
|
menu.entry(
|
||||||
"Copy Path",
|
"Copy Path",
|
||||||
Some(Box::new(zed_actions::workspace::CopyPath)),
|
Some(Box::new(zed_actions::workspace::CopyPath)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue