From 564f52e76faad1f34b9d8a95c2f36719f3408a6b Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Fri, 24 Jul 2026 17:19:21 +0800 Subject: [PATCH] test(lsp): use a host-shaped absolute path in the URI round-trip `Url::from_file_path` rejects a POSIX literal on Windows, so the test panicked there instead of exercising the percent-encoding it is about. --- src/ui/lsp.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ui/lsp.rs b/src/ui/lsp.rs index caabb84b..439c599a 100644 --- a/src/ui/lsp.rs +++ b/src/ui/lsp.rs @@ -596,7 +596,14 @@ mod tests { #[test] fn uri_round_trips_paths_with_spaces() { - let p = Path::new("/tmp/a dir/file.rs"); + // `Url::from_file_path` requires an *absolute* path in the host's own + // shape, so a POSIX literal here would simply fail to convert on + // Windows rather than exercise the percent-encoding under test. + let p = if cfg!(windows) { + Path::new(r"C:\tmp\a dir\file.rs") + } else { + Path::new("/tmp/a dir/file.rs") + }; let uri = uri_for_path(p).unwrap(); assert!(uri.starts_with("file:///")); assert!(uri.contains("a%20dir"));