mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-18 14:21:32 +03:00
fix: file list expansion arguments ($@
, $*
) of shell command under opener rules are out of order (#890)
This commit is contained in:
parent
884de41b66
commit
e7dc971416
@ -15,7 +15,7 @@ impl Manager {
|
||||
};
|
||||
|
||||
let cwd = self.cwd().clone();
|
||||
let old: Vec<_> = self.selected_or_hovered(true);
|
||||
let old: Vec<_> = self.selected_or_hovered(true).collect();
|
||||
|
||||
let root = max_common_root(&old);
|
||||
let old: Vec<_> = old.into_iter().map(|p| p.strip_prefix(&root).unwrap().to_owned()).collect();
|
||||
|
@ -33,7 +33,9 @@ impl Manager {
|
||||
};
|
||||
|
||||
let opt = opt.into() as Opt;
|
||||
let selected = if opt.hovered { vec![&hovered] } else { self.selected_or_hovered(false) };
|
||||
let selected =
|
||||
if opt.hovered { vec![&hovered] } else { self.selected_or_hovered(true).collect() };
|
||||
|
||||
if Self::quit_with_selected(&selected) {
|
||||
return;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ impl Manager {
|
||||
}
|
||||
|
||||
let mut opt = opt.into() as Opt;
|
||||
opt.targets = self.selected_or_hovered(false).into_iter().cloned().collect();
|
||||
opt.targets = self.selected_or_hovered(false).cloned().collect();
|
||||
|
||||
if opt.force {
|
||||
return self.remove_do(opt, tasks);
|
||||
|
@ -17,10 +17,8 @@ impl Manager {
|
||||
return;
|
||||
}
|
||||
|
||||
self.yanked = Yanked {
|
||||
cut: opt.into().cut,
|
||||
urls: self.selected_or_hovered(false).into_iter().cloned().collect(),
|
||||
};
|
||||
self.yanked =
|
||||
Yanked { cut: opt.into().cut, urls: self.selected_or_hovered(false).cloned().collect() };
|
||||
|
||||
self.active_mut().escape_select();
|
||||
Pubsub::pub_from_yank(self.yanked.cut, &self.yanked.urls);
|
||||
|
@ -53,10 +53,12 @@ impl Manager {
|
||||
pub fn hovered_folder(&self) -> Option<&Folder> { self.tabs.active().hovered_folder() }
|
||||
|
||||
#[inline]
|
||||
pub fn selected_or_hovered(&self, sorted: bool) -> Vec<&Url> {
|
||||
self.tabs.active().selected_or_hovered(sorted)
|
||||
pub fn selected_or_hovered(&self, reorder: bool) -> Box<dyn Iterator<Item = &Url> + '_> {
|
||||
self.tabs.active().selected_or_hovered(reorder)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hovered_and_selected(&self) -> Vec<&Url> { self.tabs.active().hovered_and_selected() }
|
||||
pub fn hovered_and_selected(&self, reorder: bool) -> Box<dyn Iterator<Item = &Url> + '_> {
|
||||
self.tabs.active().hovered_and_selected(reorder)
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ impl Tab {
|
||||
}
|
||||
|
||||
let mut s = OsString::new();
|
||||
let mut it = self.selected_or_hovered(true).into_iter().peekable();
|
||||
let mut it = self.selected_or_hovered(true).peekable();
|
||||
while let Some(u) = it.next() {
|
||||
s.push(match opt.type_.as_str() {
|
||||
"path" => u.as_os_str(),
|
||||
|
@ -31,7 +31,7 @@ impl Tab {
|
||||
}
|
||||
|
||||
let mut opt = opt.into() as Opt;
|
||||
let selected = self.hovered_and_selected().into_iter().cloned().collect();
|
||||
let selected = self.hovered_and_selected(true).cloned().collect();
|
||||
|
||||
tokio::spawn(async move {
|
||||
if !opt.confirm || opt.run.is_empty() {
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::collections::HashMap;
|
||||
use std::{collections::HashMap, iter};
|
||||
|
||||
use anyhow::Result;
|
||||
use tokio::task::JoinHandle;
|
||||
@ -34,27 +34,29 @@ impl Tab {
|
||||
|
||||
impl Tab {
|
||||
// --- Current
|
||||
pub fn selected_or_hovered(&self, sorted: bool) -> Vec<&Url> {
|
||||
pub fn selected_or_hovered(&self, reorder: bool) -> Box<dyn Iterator<Item = &Url> + '_> {
|
||||
if self.selected.is_empty() {
|
||||
self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default()
|
||||
} else if !sorted {
|
||||
self.selected.keys().collect()
|
||||
Box::new(self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default().into_iter())
|
||||
} else if !reorder {
|
||||
Box::new(self.selected.keys())
|
||||
} else {
|
||||
let mut vec: Vec<_> = self.selected.iter().collect();
|
||||
vec.sort_unstable_by(|a, b| a.1.cmp(b.1));
|
||||
vec.into_iter().map(|(k, _)| k).collect()
|
||||
Box::new(vec.into_iter().map(|(k, _)| k))
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hovered_and_selected(&self) -> Vec<&Url> {
|
||||
let Some(h) = self.current.hovered() else {
|
||||
return vec![];
|
||||
};
|
||||
pub fn hovered_and_selected(&self, reorder: bool) -> Box<dyn Iterator<Item = &Url> + '_> {
|
||||
let Some(h) = self.current.hovered() else { return Box::new(iter::empty()) };
|
||||
|
||||
if self.selected.is_empty() {
|
||||
vec![&h.url, &h.url]
|
||||
Box::new([&h.url, &h.url].into_iter())
|
||||
} else if !reorder {
|
||||
Box::new([&h.url].into_iter().chain(self.selected.keys()))
|
||||
} else {
|
||||
[&h.url].into_iter().chain(self.selected.keys()).collect()
|
||||
let mut vec: Vec<_> = self.selected.iter().collect();
|
||||
vec.sort_unstable_by(|a, b| a.1.cmp(b.1));
|
||||
Box::new([&h.url].into_iter().chain(vec.into_iter().map(|(k, _)| k)))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user