From b8cc2dcae81d870639853ef4a101a19b3bd00fc7 Mon Sep 17 00:00:00 2001 From: hankertrix <91734413+hankertrix@users.noreply.github.com> Date: Fri, 28 Jun 2024 00:49:42 +0800 Subject: [PATCH] Add hovered option to rename command --- yazi-core/src/manager/commands/rename.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/yazi-core/src/manager/commands/rename.rs b/yazi-core/src/manager/commands/rename.rs index b8cfc4dd..c85ce988 100644 --- a/yazi-core/src/manager/commands/rename.rs +++ b/yazi-core/src/manager/commands/rename.rs @@ -10,26 +10,29 @@ use yazi_shared::{event::Cmd, fs::{maybe_exists, ok_or_not_found, paths_to_same_ use crate::manager::Manager; pub struct Opt { - force: bool, - empty: String, - cursor: String, + force: bool, + hovered: bool, + empty: String, + cursor: String, } impl From for Opt { fn from(mut c: Cmd) -> Self { Self { - force: c.bool("force"), - empty: c.take_str("empty").unwrap_or_default(), - cursor: c.take_str("cursor").unwrap_or_default(), + force: c.bool("force"), + hovered: c.bool("hovered"), + empty: c.take_str("empty").unwrap_or_default(), + cursor: c.take_str("cursor").unwrap_or_default(), } } } impl Manager { pub fn rename(&mut self, opt: impl Into) { + let opt = opt.into() as Opt; if !self.active_mut().try_escape_visual() { return; - } else if !self.active().selected.is_empty() { + } else if !opt.hovered && !self.active().selected.is_empty() { return self.bulk_rename(); } @@ -37,7 +40,6 @@ impl Manager { return; }; - let opt = opt.into() as Opt; let name = Self::empty_url_part(&hovered, &opt.empty); let cursor = match opt.cursor.as_str() { "start" => Some(0),