mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
project_panel: Double-click on blank space in project panel to create a new file (#15353)
Similar feature implemented in VSCode. https://github.com/user-attachments/assets/ae250b5f-283c-4211-8947-d5d5703eb2d0 Release Notes: - Added double-click to create a new file when clicking on blank space in the project panel.
This commit is contained in:
parent
b8f20053d8
commit
f124ca6474
@ -2144,6 +2144,8 @@ impl ProjectPanel {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !show_editor {
|
if !show_editor {
|
||||||
|
cx.stop_propagation();
|
||||||
|
|
||||||
if let Some(selection) =
|
if let Some(selection) =
|
||||||
this.selection.filter(|_| event.down.modifiers.shift)
|
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::copy))
|
||||||
.on_action(cx.listener(Self::paste))
|
.on_action(cx.listener(Self::paste))
|
||||||
.on_action(cx.listener(Self::duplicate))
|
.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| {
|
.when(project.is_local(), |el| {
|
||||||
el.on_action(cx.listener(Self::reveal_in_finder))
|
el.on_action(cx.listener(Self::reveal_in_finder))
|
||||||
|
Loading…
Reference in New Issue
Block a user