Centralize the CopyPath and CopyRelativePath actions to zed_actions (#24836)

I spent an hour with @marcospb19 this morning debugging an issue with
adding `Copy Path` and `Copy Relative Path` actions to the editor
context menu. Turned out that the problem was using
`workspace::CopyPath` in the menu and `editor::CopyPath` in the action
handler.

This is an easy mistake to make, so let's fix it for everyone.

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki 2025-02-13 15:30:44 -08:00 committed by GitHub
parent 28c667a3c7
commit 5d26ce14d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 84 additions and 31 deletions

View file

@ -38,6 +38,7 @@ ui.workspace = true
util.workspace = true
workspace.workspace = true
worktree.workspace = true
zed_actions.workspace = true
[dev-dependencies]
search = { workspace = true, features = ["test-support"] }

View file

@ -67,8 +67,6 @@ actions!(
[
CollapseAllEntries,
CollapseSelectedEntry,
CopyPath,
CopyRelativePath,
ExpandAllEntries,
ExpandSelectedEntry,
FoldDirectory,
@ -1361,8 +1359,11 @@ impl OutlinePanel {
menu.action("Fold Directory", Box::new(FoldDirectory))
})
.separator()
.action("Copy Path", Box::new(CopyPath))
.action("Copy Relative Path", Box::new(CopyRelativePath))
.action("Copy Path", Box::new(zed_actions::workspace::CopyPath))
.action(
"Copy Relative Path",
Box::new(zed_actions::workspace::CopyRelativePath),
)
});
window.focus(&context_menu.focus_handle(cx));
let subscription = cx.subscribe(&context_menu, |outline_panel, _, _: &DismissEvent, cx| {
@ -1827,7 +1828,12 @@ impl OutlinePanel {
})
}
fn copy_path(&mut self, _: &CopyPath, _: &mut Window, cx: &mut Context<Self>) {
fn copy_path(
&mut self,
_: &zed_actions::workspace::CopyPath,
_: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(clipboard_text) = self
.selected_entry()
.and_then(|entry| self.abs_path(entry, cx))
@ -1837,7 +1843,12 @@ impl OutlinePanel {
}
}
fn copy_relative_path(&mut self, _: &CopyRelativePath, _: &mut Window, cx: &mut Context<Self>) {
fn copy_relative_path(
&mut self,
_: &zed_actions::workspace::CopyRelativePath,
_: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(clipboard_text) = self
.selected_entry()
.and_then(|entry| match entry {