Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Paste: the file-link test builds proper file URLs on Windows too (#3348) (#3494)

cronos7c6845da9529
diff --git a/crates/ui-egui/src/agent_chat/paste.rs b/crates/ui-egui/src/agent_chat/paste.rs
index 2d722ca9e2..0dd8c5c279 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));