Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

windows: Fix sometimes log error messages don't show the crate name (#18706)

Junkui Zhang8d6fa9526e07
diff --git a/crates/util/src/util.rs b/crates/util/src/util.rs
index a161b8bac2b..50fc070009e 100644
--- a/crates/util/src/util.rs
+++ b/crates/util/src/util.rs
@@ -378,9 +378,13 @@ fn log_error_with_caller<E>(caller: core::panic::Location<'_>, error: E, level:
where
E: std::fmt::Debug,
{
+ #[cfg(not(target_os = "windows"))]
+ let file = caller.file();
+ #[cfg(target_os = "windows")]
+ let file = caller.file().replace('\\', "/");
// In this codebase, the first segment of the file path is
// the 'crates' folder, followed by the crate name.
- let target = caller.file().split('/').nth(1);
+ let target = file.split('/').nth(1);
log::logger().log(
&log::Record::builder()