mirror of
https://github.com/sxyazi/yazi.git
synced 2024-12-19 14:51:42 +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 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 root = max_common_root(&old);
|
||||||
let old: Vec<_> = old.into_iter().map(|p| p.strip_prefix(&root).unwrap().to_owned()).collect();
|
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 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) {
|
if Self::quit_with_selected(&selected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ impl Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut opt = opt.into() as Opt;
|
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 {
|
if opt.force {
|
||||||
return self.remove_do(opt, tasks);
|
return self.remove_do(opt, tasks);
|
||||||
|
@ -17,10 +17,8 @@ impl Manager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.yanked = Yanked {
|
self.yanked =
|
||||||
cut: opt.into().cut,
|
Yanked { cut: opt.into().cut, urls: self.selected_or_hovered(false).cloned().collect() };
|
||||||
urls: self.selected_or_hovered(false).into_iter().cloned().collect(),
|
|
||||||
};
|
|
||||||
|
|
||||||
self.active_mut().escape_select();
|
self.active_mut().escape_select();
|
||||||
Pubsub::pub_from_yank(self.yanked.cut, &self.yanked.urls);
|
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() }
|
pub fn hovered_folder(&self) -> Option<&Folder> { self.tabs.active().hovered_folder() }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn selected_or_hovered(&self, sorted: bool) -> Vec<&Url> {
|
pub fn selected_or_hovered(&self, reorder: bool) -> Box<dyn Iterator<Item = &Url> + '_> {
|
||||||
self.tabs.active().selected_or_hovered(sorted)
|
self.tabs.active().selected_or_hovered(reorder)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[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 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() {
|
while let Some(u) = it.next() {
|
||||||
s.push(match opt.type_.as_str() {
|
s.push(match opt.type_.as_str() {
|
||||||
"path" => u.as_os_str(),
|
"path" => u.as_os_str(),
|
||||||
|
@ -31,7 +31,7 @@ impl Tab {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut opt = opt.into() as Opt;
|
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 {
|
tokio::spawn(async move {
|
||||||
if !opt.confirm || opt.run.is_empty() {
|
if !opt.confirm || opt.run.is_empty() {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::collections::HashMap;
|
use std::{collections::HashMap, iter};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
@ -34,27 +34,29 @@ impl Tab {
|
|||||||
|
|
||||||
impl Tab {
|
impl Tab {
|
||||||
// --- Current
|
// --- 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() {
|
if self.selected.is_empty() {
|
||||||
self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default()
|
Box::new(self.current.hovered().map(|h| vec![&h.url]).unwrap_or_default().into_iter())
|
||||||
} else if !sorted {
|
} else if !reorder {
|
||||||
self.selected.keys().collect()
|
Box::new(self.selected.keys())
|
||||||
} else {
|
} else {
|
||||||
let mut vec: Vec<_> = self.selected.iter().collect();
|
let mut vec: Vec<_> = self.selected.iter().collect();
|
||||||
vec.sort_unstable_by(|a, b| a.1.cmp(b.1));
|
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> {
|
pub fn hovered_and_selected(&self, reorder: bool) -> Box<dyn Iterator<Item = &Url> + '_> {
|
||||||
let Some(h) = self.current.hovered() else {
|
let Some(h) = self.current.hovered() else { return Box::new(iter::empty()) };
|
||||||
return vec![];
|
|
||||||
};
|
|
||||||
|
|
||||||
if self.selected.is_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 {
|
} 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