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));