fix: shell formatting for non-spread opener rules (#3532)

This commit is contained in:
三咲雅 misaki masa 2026-01-08 17:04:53 +08:00 committed by GitHub
parent 83674f19b4
commit ebedab3e29
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 10 deletions

View file

@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
### Fixed ### Fixed
- Account for URL covariance in `Url:join()` ([#3514]) - Account for URL covariance in `Url:join()` ([#3514])
- Fix shell formatting for non-spread opener rules ([#3532])
## [v26.1.4] ## [v26.1.4]
@ -1593,3 +1594,4 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/):
[#3494]: https://github.com/sxyazi/yazi/pull/3494 [#3494]: https://github.com/sxyazi/yazi/pull/3494
[#3514]: https://github.com/sxyazi/yazi/pull/3514 [#3514]: https://github.com/sxyazi/yazi/pull/3514
[#3518]: https://github.com/sxyazi/yazi/pull/3518 [#3518]: https://github.com/sxyazi/yazi/pull/3518
[#3532]: https://github.com/sxyazi/yazi/pull/3532

View file

@ -1,7 +1,6 @@
use anyhow::Result; use anyhow::Result;
use hashbrown::HashMap; use hashbrown::HashMap;
use yazi_config::{YAZI, popup::PickCfg}; use yazi_config::{YAZI, popup::PickCfg};
use yazi_fs::Splatter;
use yazi_macro::succ; use yazi_macro::succ;
use yazi_parser::{mgr::OpenDoOpt, tasks::ProcessOpenOpt}; use yazi_parser::{mgr::OpenDoOpt, tasks::ProcessOpenOpt};
use yazi_proxy::{PickProxy, TasksProxy}; use yazi_proxy::{PickProxy, TasksProxy};
@ -45,7 +44,7 @@ impl Actor for OpenDo {
if let Ok(choice) = pick.await { if let Ok(choice) = pick.await {
TasksProxy::open_shell_compat(ProcessOpenOpt { TasksProxy::open_shell_compat(ProcessOpenOpt {
cwd: opt.cwd, cwd: opt.cwd,
cmd: Splatter::new(&urls).splat(&openers[choice].run), cmd: openers[choice].run.clone().into(),
args: urls, args: urls,
block: openers[choice].block, block: openers[choice].block,
orphan: openers[choice].orphan, orphan: openers[choice].orphan,
@ -70,7 +69,7 @@ impl OpenDo {
for (opener, args) in openers { for (opener, args) in openers {
cx.tasks.open_shell_compat(ProcessOpenOpt { cx.tasks.open_shell_compat(ProcessOpenOpt {
cwd: cwd.clone(), cwd: cwd.clone(),
cmd: Splatter::new(&args).splat(&opener.run), cmd: opener.run.clone().into(),
args, args,
block: opener.block, block: opener.block,
orphan: opener.orphan, orphan: opener.orphan,

View file

@ -2,7 +2,6 @@ use std::borrow::Cow;
use anyhow::Result; use anyhow::Result;
use yazi_config::popup::InputCfg; use yazi_config::popup::InputCfg;
use yazi_fs::Splatter;
use yazi_macro::{act, succ}; use yazi_macro::{act, succ};
use yazi_parser::{mgr::ShellOpt, tasks::ProcessOpenOpt}; use yazi_parser::{mgr::ShellOpt, tasks::ProcessOpenOpt};
use yazi_proxy::{InputProxy, TasksProxy}; use yazi_proxy::{InputProxy, TasksProxy};
@ -40,7 +39,7 @@ impl Actor for Shell {
TasksProxy::open_shell_compat(ProcessOpenOpt { TasksProxy::open_shell_compat(ProcessOpenOpt {
cwd: cwd.into(), cwd: cwd.into(),
cmd: Splatter::new(&selected).splat(&*opt.run), cmd: opt.run.to_string().into(),
args: selected, args: selected,
block: opt.block, block: opt.block,
orphan: opt.orphan, orphan: opt.orphan,

View file

@ -1,5 +1,6 @@
use std::mem; use std::mem;
use yazi_fs::Splatter;
use yazi_parser::tasks::ProcessOpenOpt; use yazi_parser::tasks::ProcessOpenOpt;
use super::Tasks; use super::Tasks;
@ -8,6 +9,7 @@ impl Tasks {
// TODO: remove // TODO: remove
pub fn open_shell_compat(&self, mut opt: ProcessOpenOpt) { pub fn open_shell_compat(&self, mut opt: ProcessOpenOpt) {
if opt.spread { if opt.spread {
opt.cmd = Splatter::new(&opt.args).splat(opt.cmd);
self.scheduler.process_open(opt); self.scheduler.process_open(opt);
return; return;
} }
@ -15,18 +17,20 @@ impl Tasks {
return; return;
} }
if opt.args.len() == 2 { if opt.args.len() == 2 {
opt.cmd = Splatter::new(&opt.args).splat(opt.cmd);
self.scheduler.process_open(opt); self.scheduler.process_open(opt);
return; return;
} }
let hovered = mem::take(&mut opt.args[0]); let hovered = mem::take(&mut opt.args[0]);
for target in opt.args.into_iter().skip(1) { for target in opt.args.into_iter().skip(1) {
let args = vec![hovered.clone(), target];
self.scheduler.process_open(ProcessOpenOpt { self.scheduler.process_open(ProcessOpenOpt {
cwd: opt.cwd.clone(), cwd: opt.cwd.clone(),
cmd: opt.cmd.clone(), cmd: Splatter::new(&args).splat(&opt.cmd),
args: vec![hovered.clone(), target], args,
block: opt.block, block: opt.block,
orphan: opt.orphan, orphan: opt.orphan,
done: None, done: None,
spread: opt.spread, spread: opt.spread,
}); });
} }