Add hovered option to rename command

This commit is contained in:
hankertrix 2024-06-28 00:49:42 +08:00
parent 6ba7430f67
commit b8cc2dcae8

View file

@ -11,6 +11,7 @@ use crate::manager::Manager;
pub struct Opt {
force: bool,
hovered: bool,
empty: String,
cursor: String,
}
@ -19,6 +20,7 @@ impl From<Cmd> for Opt {
fn from(mut c: Cmd) -> Self {
Self {
force: c.bool("force"),
hovered: c.bool("hovered"),
empty: c.take_str("empty").unwrap_or_default(),
cursor: c.take_str("cursor").unwrap_or_default(),
}
@ -27,9 +29,10 @@ impl From<Cmd> for Opt {
impl Manager {
pub fn rename(&mut self, opt: impl Into<Opt>) {
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),