From 62b3acee5fcc454fdad46eff87a44d0c083bdfbe Mon Sep 17 00:00:00 2001 From: tims <0xtimsb@gmail.com> Date: Mon, 16 Dec 2024 18:35:54 +0530 Subject: [PATCH] Project panel: Deselect entries on remaining blank space click + Remove hover color for selected entries (#22073) Closes #22072 Clicking on the remaining space now allows a single click to deselect all selected items. Check the issue for a preview of the current state and how it works in VSCode. Bonus: I found the hover color on selected items to be distracting. When I have many entries selected and hover over them, it becomes hard to tell if a particular entry is selected while the mouse pointer is on it. This PR removes hover coloring for selected entries, mimicking how VSCode handles it. This PR: zed Release Notes: - Clicking on empty space in the Project Panel now deselects all selected items. --- crates/project_panel/src/project_panel.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 2714e70c6e..1f4fd50f41 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -3224,7 +3224,9 @@ impl ProjectPanel { .border_1() .border_r_2() .border_color(border_color) - .hover(|style| style.bg(bg_hover_color)) + .when(!is_marked && !is_active, |div| { + div.hover(|style| style.bg(bg_hover_color)) + }) .when(is_local, |div| { div.on_drag_move::(cx.listener( move |this, event: &DragMoveEvent, cx| { @@ -3897,6 +3899,11 @@ impl Render for ProjectPanel { this.hide_scrollbar(cx); } })) + .on_click(cx.listener(|this, _event, cx| { + cx.stop_propagation(); + this.selection = None; + this.marked_entries.clear(); + })) .key_context(self.dispatch_context(cx)) .on_action(cx.listener(Self::select_next)) .on_action(cx.listener(Self::select_prev))