From 5ae7fd65ee2c0c01e296d09e2583a9c7031b7e10 Mon Sep 17 00:00:00 2001 From: Matt Hunzinger Date: Thu, 20 Jun 2024 13:25:56 -0400 Subject: [PATCH] Fix hot-reloading on Windows (#2544) * Convert template path to UNIX spec to be compatible with file! macro output * Make this code windows-only --- .../src/hot_reload/hot_reloading_file_map.rs | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/packages/rsx/src/hot_reload/hot_reloading_file_map.rs b/packages/rsx/src/hot_reload/hot_reloading_file_map.rs index df2c1124d..6a213cdc1 100644 --- a/packages/rsx/src/hot_reload/hot_reloading_file_map.rs +++ b/packages/rsx/src/hot_reload/hot_reloading_file_map.rs @@ -304,14 +304,24 @@ impl FileMap { pub fn template_location(old_start: proc_macro2::LineColumn, file: &Path) -> String { let line = old_start.line; let column = old_start.column + 1; - let location = file.display().to_string() - + ":" - + &line.to_string() - + ":" - + &column.to_string() - // the byte index doesn't matter, but dioxus needs it - + ":0"; - location + + #[cfg(not(target_os = "windows"))] + let path = file.to_string_lossy().to_string(); + + #[cfg(target_os = "windows")] + let path = file + .components() + .map(|c| c.as_os_str().to_string_lossy()) + .collect::>() + .join("/"); + + path + + ":" + + &line.to_string() + + ":" + + &column.to_string() + // the byte index doesn't matter, but dioxus needs it + + ":0" } struct FileMapSearchResult {