-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes and improvements to pane
context menu
#21000
Closed
Poldraunic
wants to merge
3
commits into
zed-industries:main
from
Poldraunic:pane-context-menu-tweaks
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,6 +144,10 @@ pub struct RevealInProjectPanel { | |
pub entry_id: Option<u64>, | ||
} | ||
|
||
#[derive(Clone, PartialEq, Debug, Deserialize, Default)] | ||
#[serde(rename_all = "camelCase")] | ||
pub struct RevealInFileManager {} | ||
|
||
#[derive(Default, PartialEq, Clone, Deserialize)] | ||
pub struct DeploySearch { | ||
#[serde(default)] | ||
|
@@ -161,6 +165,7 @@ impl_actions!( | |
CloseInactiveItems, | ||
ActivateItem, | ||
RevealInProjectPanel, | ||
RevealInFileManager, | ||
DeploySearch, | ||
] | ||
); | ||
|
@@ -2212,7 +2217,9 @@ impl Pane { | |
.read(cx) | ||
.item_for_entry(entry, cx) | ||
.and_then(|item| item.project_path(cx)) | ||
.map(|project_path| project_path.path); | ||
.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(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is also sus. |
||
|
||
let entry_id = entry.to_proto(); | ||
menu = menu | ||
|
@@ -2241,19 +2248,36 @@ 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), | ||
)) | ||
}); | ||
}), | ||
) | ||
.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), | ||
)) | ||
}); | ||
}), | ||
) | ||
}) | ||
.when_some(parent_abs_path.clone(), |menu, parent_abs_path| { | ||
let reveal_in_finder_label = if cfg!(target_os = "macos") { | ||
"Reveal in Finder" | ||
} else { | ||
"Reveal in File Manager" | ||
}; | ||
|
||
menu.entry( | ||
reveal_in_finder_label, | ||
Some(Box::new(RevealInFileManager {})), | ||
cx.handler_for(&pane, move |_, cx| { | ||
cx.reveal_path(&parent_abs_path); | ||
}), | ||
) | ||
}) | ||
.when_some(parent_abs_path, |menu, parent_abs_path| { | ||
menu.entry( | ||
"Open in Terminal", | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed it down to this
zed/crates/project/src/worktree_store.rs
Lines 148 to 159 in 74223c1
I am not familiar how
Worktree
s work yet, but it seems that even for a single out-of-project fileWorktree
is created with the samePath
. Meaning thisPath::strip_prefix()
will nuke whole path and we'll be left with empty string.I considered checking paths here for equality and returning
None
if they're equal. This code is pretty low level and I don't know if this would be correct thing to do.