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

@ -63,6 +63,7 @@ theme.workspace = true
ui.workspace = true
util.workspace = true
uuid.workspace = true
zed_actions.workspace = true
[dev-dependencies]
call = { workspace = true, features = ["test-support"] }

View file

@ -7,8 +7,8 @@ use crate::{
notifications::NotifyResultExt,
toolbar::Toolbar,
workspace_settings::{AutosaveSetting, TabBarSettings, WorkspaceSettings},
CloseWindow, CopyPath, CopyRelativePath, NewFile, NewTerminal, OpenInTerminal, OpenTerminal,
OpenVisible, SplitDirection, ToggleFileFinder, ToggleProjectSymbols, ToggleZoom, Workspace,
CloseWindow, NewFile, NewTerminal, OpenInTerminal, OpenTerminal, OpenVisible, SplitDirection,
ToggleFileFinder, ToggleProjectSymbols, ToggleZoom, Workspace,
};
use anyhow::Result;
use collections::{BTreeSet, HashMap, HashSet, VecDeque};
@ -2552,7 +2552,7 @@ impl Pane {
.when_some(entry_abs_path, |menu, abs_path| {
menu.entry(
"Copy Path",
Some(Box::new(CopyPath)),
Some(Box::new(zed_actions::workspace::CopyPath)),
window.handler_for(&pane, move |_, _, cx| {
cx.write_to_clipboard(ClipboardItem::new_string(
abs_path.to_string_lossy().to_string(),
@ -2563,7 +2563,7 @@ impl Pane {
.when_some(relative_path, |menu, relative_path| {
menu.entry(
"Copy Relative Path",
Some(Box::new(CopyRelativePath)),
Some(Box::new(zed_actions::workspace::CopyRelativePath)),
window.handler_for(&pane, move |_, _, cx| {
cx.write_to_clipboard(ClipboardItem::new_string(
relative_path.to_string_lossy().to_string(),

View file

@ -133,8 +133,6 @@ actions!(
ClearAllNotifications,
CloseAllDocks,
CloseWindow,
CopyPath,
CopyRelativePath,
Feedback,
FollowNextCollaborator,
MoveFocusedPanelToNextPosition,