From f5320dbdd26244b80167cb9c4375155a46d3c96a Mon Sep 17 00:00:00 2001 From: YoVinchen Date: Mon, 30 Mar 2026 10:24:48 +0800 Subject: [PATCH] fix(terminal): restore UNC paths when stripping Windows verbatim prefix Handle \\?\UNC\server\share form separately from regular \\?\ prefix, converting it back to \\server\share so network/WSL directory paths remain valid in batch cd commands. --- src-tauri/src/commands/misc.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/commands/misc.rs b/src-tauri/src/commands/misc.rs index 7e3337dc..fb6b980f 100644 --- a/src-tauri/src/commands/misc.rs +++ b/src-tauri/src/commands/misc.rs @@ -813,12 +813,15 @@ fn resolve_launch_cwd(cwd: Option) -> Result, String> { return Err(format!("选择的路径不是文件夹: {}", resolved.display())); } - // Strip Windows extended-length prefix (\\?\) that canonicalize produces, + // Strip Windows extended-length prefix that canonicalize produces, // as it can break batch scripts and other shell commands. + // Special-case \\?\UNC\server\share -> \\server\share for network/WSL paths. #[cfg(target_os = "windows")] let resolved = { let s = resolved.to_string_lossy(); - if let Some(stripped) = s.strip_prefix(r"\\?\") { + if let Some(unc) = s.strip_prefix(r"\\?\UNC\") { + PathBuf::from(format!(r"\\{unc}")) + } else if let Some(stripped) = s.strip_prefix(r"\\?\") { PathBuf::from(stripped) } else { resolved