Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add option to disable crash handler (#40799)
Niabd69124f2b4f
diff --git a/crates/crashes/src/crashes.rs b/crates/crashes/src/crashes.rsindex 4a45961970c..62455d552e8 100644--- a/crates/crashes/src/crashes.rs+++ b/crates/crashes/src/crashes.rs@@ -33,17 +33,31 @@ const CRASH_HANDLER_CONNECT_TIMEOUT: Duration = Duration::from_secs(10);static PANIC_THREAD_ID: AtomicU32 = AtomicU32::new(0);pub async fn init(crash_init: InitCrashHandler) {- if *RELEASE_CHANNEL == ReleaseChannel::Dev && env::var("ZED_GENERATE_MINIDUMPS").is_err() {- let old_hook = panic::take_hook();- panic::set_hook(Box::new(move |info| {- unsafe { env::set_var("RUST_BACKTRACE", "1") };- old_hook(info);- // prevent the macOS crash dialog from popping up- std::process::exit(1);- }));- return;- } else {- panic::set_hook(Box::new(panic_hook));+ let gen_var = match env::var("ZED_GENERATE_MINIDUMPS") {+ Ok(v) => {+ if v == "false" || v == "0" {+ Some(false)+ } else {+ Some(true)+ }+ }+ Err(_) => None,+ };++ match (gen_var, *RELEASE_CHANNEL) {+ (Some(false), _) | (None, ReleaseChannel::Dev) => {+ let old_hook = panic::take_hook();+ panic::set_hook(Box::new(move |info| {+ unsafe { env::set_var("RUST_BACKTRACE", "1") };+ old_hook(info);+ // prevent the macOS crash dialog from popping up+ std::process::exit(1);+ }));+ return;+ }+ (Some(true), _) | (None, _) => {+ panic::set_hook(Box::new(panic_hook));+ }}let exe = env::current_exe().expect("unable to find ourselves");