From 7c6845da9529a339ec47470c7b53d3f474450e56 Mon Sep 17 00:00:00 2001 From: cronos Date: Tue, 20 Oct 2026 12:42:43 +0000 Subject: [PATCH] Paste: the file-link test builds proper file URLs on Windows too (#3348) (#3494) The test turned a temp path into a link with `file://` + the path, which on Windows gives `file://C:\Users\...`, not a file URL, so the test failed there. It now builds `file:///C:/Users/.../my%20part.stl` on Windows (what Explorer and browsers put on the clipboard) and `file:///tmp/...` on Linux and macOS, as before. `files_in_text` already reads Windows file URLs correctly; the fixed test now checks that on Windows. Co-authored-by: Ray --- crates/ui-egui/src/agent_chat/paste.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/agent_chat/paste.rs b/crates/ui-egui/src/agent_chat/paste.rs index 2d722ca9e..0dd8c5c27 100644 --- a/crates/ui-egui/src/agent_chat/paste.rs +++ b/crates/ui-egui/src/agent_chat/paste.rs @@ -201,7 +201,11 @@ mod tests { std::fs::write(&spaced, b"solid").unwrap(); let plain = d.join("brief.md"); std::fs::write(&plain, b"x").unwrap(); - let link = |p: &Path| format!("file://{}", p.to_string_lossy().replace(' ', "%20")); + // A proper file URL on every system: `file:///tmp/a%20b`, `file:///C:/Users/a%20b`. + let link = |p: &Path| { + let path = p.to_string_lossy().replace(std::path::MAIN_SEPARATOR, "/").replace(' ', "%20"); + format!("file://{}{path}", if path.starts_with('/') { "" } else { "/" }) + }; let list = format!("# copied\n{}\r\n{}\n", link(&spaced), link(&plain)); assert_eq!(files_in_text(&list), vec![spaced.clone(), plain.clone()]); assert!(matches!(decide(Some(&list), &mut Fake::default()), Paste::Files(f) if f.len() == 2));