Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

project_panel: Add rename, delete and duplicate actions to workspace (#34478)

Smit Barmase729cde33f14b
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index e1d360cd976..b6fdcd6fa5b 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -320,6 +320,33 @@ pub fn init(cx: &mut App) {
});
}
});
+
+ workspace.register_action(|workspace, action: &Rename, window, cx| {
+ if let Some(panel) = workspace.panel::<ProjectPanel>(cx) {
+ panel.update(cx, |panel, cx| {
+ if let Some(first_marked) = panel.marked_entries.first() {
+ let first_marked = *first_marked;
+ panel.marked_entries.clear();
+ panel.selection = Some(first_marked);
+ }
+ panel.rename(action, window, cx);
+ });
+ }
+ });
+
+ workspace.register_action(|workspace, action: &Duplicate, window, cx| {
+ if let Some(panel) = workspace.panel::<ProjectPanel>(cx) {
+ panel.update(cx, |panel, cx| {
+ panel.duplicate(action, window, cx);
+ });
+ }
+ });
+
+ workspace.register_action(|workspace, action: &Delete, window, cx| {
+ if let Some(panel) = workspace.panel::<ProjectPanel>(cx) {
+ panel.update(cx, |panel, cx| panel.delete(action, window, cx));
+ }
+ });
})
.detach();
}