Fix hot-reloading on Windows (#2544)
* Convert template path to UNIX spec to be compatible with file! macro output * Make this code windows-only
This commit is contained in:
1 parent
1fdee2d47a
commit
5ae7fd65ee
1 file changed
+18
-8
@@ -304,14 +304,24 @@ impl<Ctx: HotReloadingContext> FileMap<Ctx> {
|
||||
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::<Vec<_>>()
|
||||
.join("/");
|
||||
|
||||
path
|
||||
+ ":"
|
||||
+ &line.to_string()
|
||||
+ ":"
|
||||
+ &column.to_string()
|
||||
// the byte index doesn't matter, but dioxus needs it
|
||||
+ ":0"
|
||||
}
|
||||
|
||||
struct FileMapSearchResult {
|
||||
|
||||
Reference in new issue
Block a user