Skip to content

Commit

Permalink
Make this code windows-only
Browse files Browse the repository at this point in the history
  • Loading branch information
matthunz committed Jun 19, 2024
1 parent 699eb66 commit 21478ca
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions packages/rsx/src/hot_reload/hot_reloading_file_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub use proc_macro2::TokenStream;
pub use std::collections::HashMap;
pub use std::sync::Mutex;
pub use std::time::SystemTime;
use std::{collections::HashSet, ffi::OsStr, fmt::format, marker::PhantomData, path::PathBuf};
use std::{collections::HashSet, ffi::OsStr, marker::PhantomData, path::PathBuf};
pub use std::{fs, io, path::Path};
pub use std::{fs::File, io::Read};
use syn::spanned::Spanned;
Expand Down Expand Up @@ -304,17 +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

#[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().to_owned())
.collect::<Vec<_>>().join("/")
+ ":"
+ &line.to_string()
+ ":"
+ &column.to_string()
// the byte index doesn't matter, but dioxus needs it
+ ":0";
location
.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 {
Expand Down

0 comments on commit 21478ca

Please sign in to comment.