Skip to content

Commit

Permalink
fix: don't check if has a hovered file in advance, only do so when `-…
Browse files Browse the repository at this point in the history
…-hovered` is explicitly specified (#2105)
  • Loading branch information
sxyazi authored Dec 27, 2024
1 parent 94128b4 commit 2770e02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
9 changes: 4 additions & 5 deletions yazi-core/src/manager/commands/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ impl Manager {
if !self.active_mut().try_escape_visual() {
return;
}
let Some(hovered) = self.hovered().map(|h| &h.url) else {
return;
};

opt.targets = if opt.hovered {
vec![hovered.clone()]
self.hovered().map_or(vec![], |h| vec![h.url.clone()])
} else {
self.selected_or_hovered(true).cloned().collect()
};

if opt.force {
if opt.targets.is_empty() {
return;
} else if opt.force {
return self.remove_do(opt, tasks);
}

Expand Down
7 changes: 3 additions & 4 deletions yazi-core/src/manager/commands/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,14 @@ impl Manager {
pub fn rename(&mut self, opt: Opt) {
if !self.active_mut().try_escape_visual() {
return;
} else if !opt.hovered && !self.active().selected.is_empty() {
return self.bulk_rename();
}

let Some(hovered) = self.hovered().map(|h| h.url_owned()) else {
return;
};

if !opt.hovered && !self.active().selected.is_empty() {
return self.bulk_rename();
}

let name = Self::empty_url_part(&hovered, &opt.empty);
let cursor = match opt.cursor.as_ref() {
"start" => Some(0),
Expand Down

0 comments on commit 2770e02

Please sign in to comment.