From 15b2556b5648399ac48740b83e3f0a591dfbcd9a Mon Sep 17 00:00:00 2001 From: hankertrix <91734413+hankertrix@users.noreply.github.com> Date: Wed, 13 Mar 2024 14:02:30 +0800 Subject: [PATCH] feat!: Only return selected when hover is selected With the cross-directory selection feature, it can be very unexpected to select items in a parent directory, then go into a child directory to attempt to open a file, but instead of opening the hovered file, the selected items are opened instead. This is especially obvious when using the smart-enter plugin that combines the enter and open command together. For the most part, users are most likely going to be hovering over a selected item if they want to operate on the items that they have selected, so this change will likely result in a net improvement in user experience. --- yazi-core/src/tab/tab.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/yazi-core/src/tab/tab.rs b/yazi-core/src/tab/tab.rs index 0a36c1f4..8bbfc013 100644 --- a/yazi-core/src/tab/tab.rs +++ b/yazi-core/src/tab/tab.rs @@ -51,8 +51,11 @@ impl From<&Url> for Tab { impl Tab { // --- Current pub fn selected_or_hovered(&self) -> Vec<&Url> { + let hovered = self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default(); if self.selected.is_empty() { - self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default() + hovered + } else if !self.selected.contains(hovered[0]) { + hovered } else { self.selected.iter().collect() }