diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-17 01:10:07 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-17 01:10:07 +0800 |
| commit | e17117e027cf8f0aa077c861b707651e040800a0 (patch) | |
| tree | 0c0cc10932f59bb6bee6b3328a0f7a710eee88ca /mingling_core/src/program.rs | |
| parent | cbb77a0569b6b79f51767180cb47cf50e68cf18c (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.rs | 14 |
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(), |
