From c202c8cffc3bd64b5cf3fdc2741f5bead0f656d0 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 20 Sep 2024 09:09:39 -0600 Subject: [PATCH] Clear selection when right clicking empty space, fixes #361 --- src/tab.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/tab.rs b/src/tab.rs index 4ef36f6..18b8bba 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -1230,6 +1230,7 @@ pub struct Tab { cached_selected: RefCell>, clicked: Option, selected_clicked: bool, + last_right_click: Option, } fn folder_name>(path: P) -> (String, bool) { @@ -1276,6 +1277,7 @@ impl Tab { clicked: None, dnd_hovered: None, selected_clicked: false, + last_right_click: None, } } @@ -1766,6 +1768,14 @@ impl Tab { Message::ContextMenu(point_opt) => { if point_opt.is_none() || !mod_shift { self.context_menu = point_opt; + //TODO: hack for clearing selecting when right clicking empty space + if self.context_menu.is_some() && self.last_right_click.take().is_none() { + if let Some(ref mut items) = self.items_opt { + for item in items.iter_mut() { + item.selected = false; + } + } + } } } Message::LocationContextMenuPoint(point_opt) => { @@ -2040,6 +2050,8 @@ impl Tab { } } } + //TODO: hack for clearing selecting when right clicking empty space + self.last_right_click = click_i_opt; } Message::MiddleClick(click_i) => { self.update(Message::Click(Some(click_i)), modifiers);