aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-17 01:10:07 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-17 01:10:07 +0800
commite17117e027cf8f0aa077c861b707651e040800a0 (patch)
tree0c0cc10932f59bb6bee6b3328a0f7a710eee88ca /mingling_core/src/program.rs
parentcbb77a0569b6b79f51767180cb47cf50e68cf18c (diff)
Fix Windows UTF-16 argument handling in PowerShell completion
Diffstat (limited to 'mingling_core/src/program.rs')
-rw-r--r--mingling_core/src/program.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs
index bee9772..7ea3a38 100644
--- a/mingling_core/src/program.rs
+++ b/mingling_core/src/program.rs
@@ -8,7 +8,7 @@ use crate::{
AnyOutput, ChainProcess, RenderResult, asset::dispatcher::Dispatcher,
error::ProgramExecuteError,
};
-use std::{env, fmt::Display, pin::Pin, sync::OnceLock};
+use std::{fmt::Display, pin::Pin, sync::OnceLock};
#[doc(hidden)]
pub mod exec;
@@ -74,7 +74,19 @@ where
Program {
collect: std::marker::PhantomData,
group: std::marker::PhantomData,
+ #[cfg(not(windows))]
args: env::args().collect(),
+ #[cfg(windows)]
+ args: {
+ std::env::args_os()
+ .map(|arg| {
+ use std::os::windows::ffi::OsStrExt;
+
+ let wide: Vec<u16> = arg.encode_wide().collect();
+ String::from_utf16_lossy(&wide)
+ })
+ .collect()
+ },
dispatcher: Vec::new(),
stdout_setting: Default::default(),
user_context: Default::default(),