Skip to content

Commit 2b1f7d5

Browse files
authored
project_panel: Fix primary and secondary click on blank area (#38139)
Follow up #38008 Release Notes: - N/A
1 parent 813a9bb commit 2b1f7d5

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

crates/project_panel/src/project_panel.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5203,14 +5203,6 @@ impl Render for ProjectPanel {
52035203
this.refresh_drag_cursor_style(&event.modifiers, window, cx);
52045204
},
52055205
))
5206-
.on_click(cx.listener(|this, event, _, cx| {
5207-
if matches!(event, gpui::ClickEvent::Keyboard(_)) {
5208-
return;
5209-
}
5210-
cx.stop_propagation();
5211-
this.selection = None;
5212-
this.marked_entries.clear();
5213-
}))
52145206
.key_context(self.dispatch_context(window, cx))
52155207
.on_action(cx.listener(Self::select_next))
52165208
.on_action(cx.listener(Self::select_previous))
@@ -5280,16 +5272,6 @@ impl Render for ProjectPanel {
52805272
.when(project.is_via_remote_server(), |el| {
52815273
el.on_action(cx.listener(Self::open_in_terminal))
52825274
})
5283-
.on_mouse_down(
5284-
MouseButton::Right,
5285-
cx.listener(move |this, event: &MouseDownEvent, window, cx| {
5286-
// When deploying the context menu anywhere below the last project entry,
5287-
// act as if the user clicked the root of the last worktree.
5288-
if let Some(entry_id) = this.last_worktree_root_id {
5289-
this.deploy_context_menu(event.position, entry_id, window, cx);
5290-
}
5291-
}),
5292-
)
52935275
.track_focus(&self.focus_handle(cx))
52945276
.child(
52955277
v_flex()
@@ -5507,6 +5489,7 @@ impl Render for ProjectPanel {
55075489
)
55085490
.child(
55095491
div()
5492+
.id("project-panel-blank-area")
55105493
.block_mouse_except_scroll()
55115494
.flex_grow()
55125495
.when(
@@ -5588,7 +5571,30 @@ impl Render for ProjectPanel {
55885571
}
55895572
cx.stop_propagation();
55905573
},
5591-
)),
5574+
))
5575+
.on_click(cx.listener(|this, event, _, cx| {
5576+
if matches!(event, gpui::ClickEvent::Keyboard(_)) {
5577+
return;
5578+
}
5579+
cx.stop_propagation();
5580+
this.selection = None;
5581+
this.marked_entries.clear();
5582+
}))
5583+
.on_mouse_down(
5584+
MouseButton::Right,
5585+
cx.listener(move |this, event: &MouseDownEvent, window, cx| {
5586+
// When deploying the context menu anywhere below the last project entry,
5587+
// act as if the user clicked the root of the last worktree.
5588+
if let Some(entry_id) = this.last_worktree_root_id {
5589+
this.deploy_context_menu(
5590+
event.position,
5591+
entry_id,
5592+
window,
5593+
cx,
5594+
);
5595+
}
5596+
}),
5597+
),
55925598
)
55935599
.size_full(),
55945600
)

0 commit comments

Comments
 (0)