From c9ac828ec773ad37f5fa5c12cfc610e9506d6ab8 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Tue, 28 Jun 2022 10:00:02 -0500 Subject: [PATCH] fix path seperator --- src/server/hot_reload.rs | 9 ++++++--- src/server/mod.rs | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/server/hot_reload.rs b/src/server/hot_reload.rs index ea9c64fc7..d34f079f5 100644 --- a/src/server/hot_reload.rs +++ b/src/server/hot_reload.rs @@ -97,6 +97,7 @@ pub async fn hot_reload_handler( if let DiffResult::RsxChanged(changed) = find_rsx(&new_file, &old_file) { for (old, new) in changed.into_iter() { let hr = get_location( + &state.watcher_config.crate_dir, k, old.to_token_stream(), ); @@ -150,7 +151,7 @@ pub async fn hot_reload_handler( let error: Error = serde_json::from_str(&err).unwrap(); match error{ Error::ParseError(parse_error) => { - log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file, parse_error.location.line, parse_error.location.column, parse_error.message); + log::error!("parse error:\n--> at {}:{}:{}\n\t{:?}", parse_error.location.file_path, parse_error.location.line, parse_error.location.column, parse_error.message); }, Error::RecompileRequiredError(_) => { if let Err(err) = state.build_manager.build(){ @@ -182,10 +183,12 @@ pub async fn hot_reload_handler( }) } -pub fn get_location(path: &Path, ts: TokenStream) -> CodeLocation { +pub fn get_location(crate_path: &Path, path: &Path, ts: TokenStream) -> CodeLocation { let span = ts.span().start(); + let relative = path.strip_prefix(crate_path).unwrap(); CodeLocation { - file: path.display().to_string(), + file_path: relative.display().to_string(), + crate_path: crate_path.display().to_string(), line: span.line as u32, column: span.column as u32 + 1, } diff --git a/src/server/mod.rs b/src/server/mod.rs index 387355ee9..4bb08170e 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -121,6 +121,7 @@ pub async fn startup_hot_reload(config: CrateConfig) -> Result<()> { log::info!("reloading rsx"); for (old, new) in changed.into_iter() { let hr = get_location( + &crate_dir, &path.to_path_buf(), old.to_token_stream(), );