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: Double-click on blank space in project panel to create a new file (#15353)

Suhun Hanf124ca647406
diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs
index 2515e770690..585b120bd74 100644
--- a/crates/project_panel/src/project_panel.rs
+++ b/crates/project_panel/src/project_panel.rs
@@ -2144,6 +2144,8 @@ impl ProjectPanel {
return;
}
if !show_editor {
+ cx.stop_propagation();
+
if let Some(selection) =
this.selection.filter(|_| event.down.modifiers.shift)
{
@@ -2437,6 +2439,28 @@ impl Render for ProjectPanel {
.on_action(cx.listener(Self::copy))
.on_action(cx.listener(Self::paste))
.on_action(cx.listener(Self::duplicate))
+ .on_click(cx.listener(|this, event: &gpui::ClickEvent, cx| {
+ if event.up.click_count > 1 {
+ if let Some(entry_id) = this.last_worktree_root_id {
+ let project = this.project.read(cx);
+
+ let worktree_id = if let Some(worktree) =
+ project.worktree_for_entry(entry_id, cx)
+ {
+ worktree.read(cx).id()
+ } else {
+ return;
+ };
+
+ this.selection = Some(SelectedEntry {
+ worktree_id,
+ entry_id,
+ });
+
+ this.new_file(&NewFile, cx);
+ }
+ }
+ }))
})
.when(project.is_local(), |el| {
el.on_action(cx.listener(Self::reveal_in_finder))