From ae9c59d132ed9be45894ebb70d2d9cbb70ce3bc1 Mon Sep 17 00:00:00 2001 From: vaisest <4550061+vaisest@users.noreply.github.com> Date: Fri, 18 Sep 2026 11:33:28 +0300 Subject: [PATCH] Fix Windows canonical paths (#59) --- src/main.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5aeb7fd..5c7614c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,10 +59,18 @@ fn find_nearby_launch_script() -> Option { for candidate in candidates { if candidate.try_exists().is_ok_and(|exists| exists) - && let Some(Ok(candidate)) = candidate.parent().map(Path::canonicalize) + && let Ok(candidate) = candidate.canonicalize() + && let Some(dir) = candidate.parent() { - return Some(candidate); - } + // remove the windows extended length path syntax as it contains a + // question mark which will interfere with lua's require() + const WINDOWS_PREFIX: &str = r#"\\?\"#; + let path_str = dir.display().to_string(); + return match path_str.strip_prefix(WINDOWS_PREFIX) { + Some(stripped) => Some(PathBuf::from(stripped)), + None => Some(dir.to_path_buf()), + }; + }; } None