1#![allow(unused_variables, dead_code, unused_mut)]
2// todo!() this is to make transition easier.
3
4// Allow binary to be called Zed for a nice application menu when running executable directly
5#![allow(non_snake_case)]
6
7use anyhow::{anyhow, Context as _, Result};
8use backtrace::Backtrace;
9use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
10use client::UserStore;
11use db::kvp::KEY_VALUE_STORE;
12use fs::RealFs;
13use futures::StreamExt;
14use gpui::{Action, App, AppContext, AsyncAppContext, Context, SemanticVersion, Task};
15use isahc::{prelude::Configurable, Request};
16use language::LanguageRegistry;
17use log::LevelFilter;
18
19use node_runtime::RealNodeRuntime;
20use parking_lot::Mutex;
21use serde::{Deserialize, Serialize};
22use settings::{
23 default_settings, handle_settings_file_changes, watch_config_file, Settings, SettingsStore,
24};
25use simplelog::ConfigBuilder;
26use smol::process::Command;
27use std::{
28 env,
29 ffi::OsStr,
30 fs::OpenOptions,
31 io::{IsTerminal, Write},
32 panic,
33 path::{Path, PathBuf},
34 sync::{
35 atomic::{AtomicU32, Ordering},
36 Arc,
37 },
38 thread,
39 time::{SystemTime, UNIX_EPOCH},
40};
41use util::{
42 async_maybe,
43 channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
44 http::{self, HttpClient},
45 paths, ResultExt,
46};
47use uuid::Uuid;
48use workspace::{AppState, WorkspaceStore};
49use zed2::{
50 build_window_options, ensure_only_instance, handle_cli_connection, initialize_workspace,
51 languages, Assets, IsOnlyInstance, OpenListener, OpenRequest,
52};
53
54mod open_listener;
55
56fn main() {
57 let http = http::client();
58 init_paths();
59 init_logger();
60
61 if ensure_only_instance() != IsOnlyInstance::Yes {
62 return;
63 }
64
65 log::info!("========== starting zed ==========");
66 let app = App::production(Arc::new(Assets));
67
68 let installation_id = app.background_executor().block(installation_id()).ok();
69 let session_id = Uuid::new_v4().to_string();
70 init_panic_hook(&app, installation_id.clone(), session_id.clone());
71
72 let fs = Arc::new(RealFs);
73 let user_settings_file_rx = watch_config_file(
74 &app.background_executor(),
75 fs.clone(),
76 paths::SETTINGS.clone(),
77 );
78 let _user_keymap_file_rx = watch_config_file(
79 &app.background_executor(),
80 fs.clone(),
81 paths::KEYMAP.clone(),
82 );
83
84 let login_shell_env_loaded = if stdout_is_a_pty() {
85 Task::ready(())
86 } else {
87 app.background_executor().spawn(async {
88 load_login_shell_environment().await.log_err();
89 })
90 };
91
92 let (listener, mut open_rx) = OpenListener::new();
93 let listener = Arc::new(listener);
94 let open_listener = listener.clone();
95 app.on_open_urls(move |urls, _| open_listener.open_urls(urls));
96 app.on_reopen(move |_cx| {
97 // todo!("workspace")
98 // if cx.has_global::<Weak<AppState>>() {
99 // if let Some(app_state) = cx.global::<Weak<AppState>>().upgrade() {
100 // workspace::open_new(&app_state, cx, |workspace, cx| {
101 // Editor::new_file(workspace, &Default::default(), cx)
102 // })
103 // .detach();
104 // }
105 // }
106 });
107
108 app.run(move |cx| {
109 cx.set_global(*RELEASE_CHANNEL);
110 load_embedded_fonts(cx);
111
112 let mut store = SettingsStore::default();
113 store
114 .set_default_settings(default_settings().as_ref(), cx)
115 .unwrap();
116 cx.set_global(store);
117 handle_settings_file_changes(user_settings_file_rx, cx);
118 // handle_keymap_file_changes(user_keymap_file_rx, cx);
119
120 let client = client::Client::new(http.clone(), cx);
121 let mut languages = LanguageRegistry::new(login_shell_env_loaded);
122 let copilot_language_server_id = languages.next_language_server_id();
123 languages.set_executor(cx.background_executor().clone());
124 languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
125 let languages = Arc::new(languages);
126 let node_runtime = RealNodeRuntime::new(http.clone());
127
128 language::init(cx);
129 languages::init(languages.clone(), node_runtime.clone(), cx);
130 let user_store = cx.build_model(|cx| UserStore::new(client.clone(), http.clone(), cx));
131 let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
132
133 cx.set_global(client.clone());
134
135 theme::init(cx);
136 // context_menu::init(cx);
137 project::Project::init(&client, cx);
138 client::init(&client, cx);
139 // command_palette::init(cx);
140 language::init(cx);
141 editor::init(cx);
142 // go_to_line::init(cx);
143 // file_finder::init(cx);
144 // outline::init(cx);
145 // project_symbols::init(cx);
146 // project_panel::init(Assets, cx);
147 // channel::init(&client, user_store.clone(), cx);
148 // diagnostics::init(cx);
149 // search::init(cx);
150 // semantic_index::init(fs.clone(), http.clone(), languages.clone(), cx);
151 // vim::init(cx);
152 // terminal_view::init(cx);
153 copilot::init(
154 copilot_language_server_id,
155 http.clone(),
156 node_runtime.clone(),
157 cx,
158 );
159 // assistant::init(cx);
160 // component_test::init(cx);
161
162 // cx.spawn(|cx| watch_themes(fs.clone(), cx)).detach();
163 // cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
164 // .detach();
165 // watch_file_types(fs.clone(), cx);
166
167 // languages.set_theme(theme::current(cx).clone());
168 // cx.observe_global::<SettingsStore, _>({
169 // let languages = languages.clone();
170 // move |cx| languages.set_theme(theme::current(cx).clone())
171 // })
172 // .detach();
173
174 // client.telemetry().start(installation_id, session_id, cx);
175
176 let app_state = Arc::new(AppState {
177 languages,
178 client: client.clone(),
179 user_store,
180 fs,
181 build_window_options,
182 initialize_workspace,
183 // background_actions: todo!("ask Mikayla"),
184 workspace_store,
185 node_runtime,
186 });
187 cx.set_global(Arc::downgrade(&app_state));
188
189 // audio::init(Assets, cx);
190 // auto_update::init(http.clone(), client::ZED_SERVER_URL.clone(), cx);
191
192 workspace::init(app_state.clone(), cx);
193 // recent_projects::init(cx);
194
195 // journal2::init(app_state.clone(), cx);
196 // language_selector::init(cx);
197 // theme_selector::init(cx);
198 // activity_indicator::init(cx);
199 // language_tools::init(cx);
200 call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
201 // collab_ui::init(&app_state, cx);
202 // feedback::init(cx);
203 // welcome::init(cx);
204 // zed::init(&app_state, cx);
205
206 // cx.set_menus(menus::menus());
207
208 if stdout_is_a_pty() {
209 cx.activate(true);
210 let urls = collect_url_args();
211 dbg!(&urls);
212 if !urls.is_empty() {
213 listener.open_urls(urls)
214 }
215 } else {
216 upload_previous_panics(http.clone(), cx);
217
218 // TODO Development mode that forces the CLI mode usually runs Zed binary as is instead
219 // of an *app, hence gets no specific callbacks run. Emulate them here, if needed.
220 if std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_some()
221 && !listener.triggered.load(Ordering::Acquire)
222 {
223 listener.open_urls(collect_url_args())
224 }
225 }
226
227 let mut _triggered_authentication = false;
228
229 fn open_paths_and_log_errs(
230 paths: &[PathBuf],
231 app_state: &Arc<AppState>,
232 cx: &mut AppContext,
233 ) {
234 let task = workspace::open_paths(&paths, &app_state, None, cx);
235 cx.spawn(|cx| async move {
236 if let Some((_window, results)) = task.await.log_err() {
237 for result in results {
238 if let Some(Err(e)) = result {
239 log::error!("Error opening path: {}", e);
240 }
241 }
242 }
243 })
244 .detach();
245 }
246
247 match open_rx.try_next() {
248 Ok(Some(OpenRequest::Paths { paths })) => {
249 open_paths_and_log_errs(&paths, &app_state, cx)
250 }
251 Ok(Some(OpenRequest::CliConnection { connection })) => {
252 let app_state = app_state.clone();
253 cx.spawn(move |cx| handle_cli_connection(connection, app_state, cx))
254 .detach();
255 }
256 Ok(Some(OpenRequest::JoinChannel { channel_id: _ })) => {
257 todo!()
258 // triggered_authentication = true;
259 // let app_state = app_state.clone();
260 // let client = client.clone();
261 // cx.spawn(|mut cx| async move {
262 // // ignore errors here, we'll show a generic "not signed in"
263 // let _ = authenticate(client, &cx).await;
264 // cx.update(|cx| workspace::join_channel(channel_id, app_state, None, cx))
265 // .await
266 // })
267 // .detach_and_log_err(cx)
268 }
269 Ok(Some(OpenRequest::OpenChannelNotes { channel_id: _ })) => {
270 todo!()
271 }
272 Ok(None) | Err(_) => cx
273 .spawn({
274 let app_state = app_state.clone();
275 |cx| async move { restore_or_create_workspace(&app_state, cx).await }
276 })
277 .detach(),
278 }
279
280 let app_state = app_state.clone();
281 cx.spawn(|cx| async move {
282 while let Some(request) = open_rx.next().await {
283 match request {
284 OpenRequest::Paths { paths } => {
285 cx.update(|cx| open_paths_and_log_errs(&paths, &app_state, cx))
286 .ok();
287 }
288 OpenRequest::CliConnection { connection } => {
289 let app_state = app_state.clone();
290 cx.spawn(move |cx| {
291 handle_cli_connection(connection, app_state.clone(), cx)
292 })
293 .detach();
294 }
295 OpenRequest::JoinChannel { channel_id: _ } => {
296 todo!()
297 }
298 OpenRequest::OpenChannelNotes { channel_id: _ } => {
299 todo!()
300 }
301 }
302 }
303 })
304 .detach();
305
306 // if !triggered_authentication {
307 // cx.spawn(|cx| async move { authenticate(client, &cx).await })
308 // .detach_and_log_err(cx);
309 // }
310 });
311}
312
313// async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
314// if stdout_is_a_pty() {
315// if client::IMPERSONATE_LOGIN.is_some() {
316// client.authenticate_and_connect(false, &cx).await?;
317// }
318// } else if client.has_keychain_credentials(&cx) {
319// client.authenticate_and_connect(true, &cx).await?;
320// }
321// Ok::<_, anyhow::Error>(())
322// }
323
324async fn installation_id() -> Result<String> {
325 let legacy_key_name = "device_id";
326
327 if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp(legacy_key_name) {
328 Ok(installation_id)
329 } else {
330 let installation_id = Uuid::new_v4().to_string();
331
332 KEY_VALUE_STORE
333 .write_kvp(legacy_key_name.to_string(), installation_id.clone())
334 .await?;
335
336 Ok(installation_id)
337 }
338}
339
340async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppContext) {
341 async_maybe!({
342 if let Some(location) = workspace::last_opened_workspace_paths().await {
343 cx.update(|cx| workspace::open_paths(location.paths().as_ref(), app_state, None, cx))?
344 .await
345 .log_err();
346 } else if matches!(KEY_VALUE_STORE.read_kvp("******* THIS IS A BAD KEY PLEASE UNCOMMENT BELOW TO FIX THIS VERY LONG LINE *******"), Ok(None)) {
347 // todo!(welcome)
348 //} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
349 //todo!()
350 // cx.update(|cx| show_welcome_experience(app_state, cx));
351 } else {
352 cx.update(|cx| {
353 workspace::open_new(app_state, cx, |workspace, cx| {
354 // todo!(editor)
355 // Editor::new_file(workspace, &Default::default(), cx)
356 })
357 .detach();
358 })?;
359 }
360 anyhow::Ok(())
361 })
362 .await
363 .log_err();
364}
365
366fn init_paths() {
367 std::fs::create_dir_all(&*util::paths::CONFIG_DIR).expect("could not create config path");
368 std::fs::create_dir_all(&*util::paths::LANGUAGES_DIR).expect("could not create languages path");
369 std::fs::create_dir_all(&*util::paths::DB_DIR).expect("could not create database path");
370 std::fs::create_dir_all(&*util::paths::LOGS_DIR).expect("could not create logs path");
371}
372
373fn init_logger() {
374 if stdout_is_a_pty() {
375 env_logger::init();
376 } else {
377 let level = LevelFilter::Info;
378
379 // Prevent log file from becoming too large.
380 const KIB: u64 = 1024;
381 const MIB: u64 = 1024 * KIB;
382 const MAX_LOG_BYTES: u64 = MIB;
383 if std::fs::metadata(&*paths::LOG).map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES)
384 {
385 let _ = std::fs::rename(&*paths::LOG, &*paths::OLD_LOG);
386 }
387
388 let log_file = OpenOptions::new()
389 .create(true)
390 .append(true)
391 .open(&*paths::LOG)
392 .expect("could not open logfile");
393
394 let config = ConfigBuilder::new()
395 .set_time_format_str("%Y-%m-%dT%T") //All timestamps are UTC
396 .build();
397
398 simplelog::WriteLogger::init(level, config, log_file).expect("could not initialize logger");
399 }
400}
401
402#[derive(Serialize, Deserialize)]
403struct LocationData {
404 file: String,
405 line: u32,
406}
407
408#[derive(Serialize, Deserialize)]
409struct Panic {
410 thread: String,
411 payload: String,
412 #[serde(skip_serializing_if = "Option::is_none")]
413 location_data: Option<LocationData>,
414 backtrace: Vec<String>,
415 app_version: String,
416 release_channel: String,
417 os_name: String,
418 os_version: Option<String>,
419 architecture: String,
420 panicked_on: u128,
421 #[serde(skip_serializing_if = "Option::is_none")]
422 installation_id: Option<String>,
423 session_id: String,
424}
425
426#[derive(Serialize)]
427struct PanicRequest {
428 panic: Panic,
429 token: String,
430}
431
432static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
433
434fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: String) {
435 let is_pty = stdout_is_a_pty();
436 let app_metadata = app.metadata();
437
438 panic::set_hook(Box::new(move |info| {
439 let prior_panic_count = PANIC_COUNT.fetch_add(1, Ordering::SeqCst);
440 if prior_panic_count > 0 {
441 // Give the panic-ing thread time to write the panic file
442 loop {
443 std::thread::yield_now();
444 }
445 }
446
447 let thread = thread::current();
448 let thread_name = thread.name().unwrap_or("<unnamed>");
449
450 let payload = info
451 .payload()
452 .downcast_ref::<&str>()
453 .map(|s| s.to_string())
454 .or_else(|| info.payload().downcast_ref::<String>().map(|s| s.clone()))
455 .unwrap_or_else(|| "Box<Any>".to_string());
456
457 if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
458 let location = info.location().unwrap();
459 let backtrace = Backtrace::new();
460 eprintln!(
461 "Thread {:?} panicked with {:?} at {}:{}:{}\n{:?}",
462 thread_name,
463 payload,
464 location.file(),
465 location.line(),
466 location.column(),
467 backtrace,
468 );
469 std::process::exit(-1);
470 }
471
472 let app_version = client::ZED_APP_VERSION
473 .or(app_metadata.app_version)
474 .map_or("dev".to_string(), |v| v.to_string());
475
476 let backtrace = Backtrace::new();
477 let mut backtrace = backtrace
478 .frames()
479 .iter()
480 .filter_map(|frame| Some(format!("{:#}", frame.symbols().first()?.name()?)))
481 .collect::<Vec<_>>();
482
483 // Strip out leading stack frames for rust panic-handling.
484 if let Some(ix) = backtrace
485 .iter()
486 .position(|name| name == "rust_begin_unwind")
487 {
488 backtrace.drain(0..=ix);
489 }
490
491 let panic_data = Panic {
492 thread: thread_name.into(),
493 payload: payload.into(),
494 location_data: info.location().map(|location| LocationData {
495 file: location.file().into(),
496 line: location.line(),
497 }),
498 app_version: app_version.clone(),
499 release_channel: RELEASE_CHANNEL.display_name().into(),
500 os_name: app_metadata.os_name.into(),
501 os_version: app_metadata
502 .os_version
503 .as_ref()
504 .map(SemanticVersion::to_string),
505 architecture: env::consts::ARCH.into(),
506 panicked_on: SystemTime::now()
507 .duration_since(UNIX_EPOCH)
508 .unwrap()
509 .as_millis(),
510 backtrace,
511 installation_id: installation_id.clone(),
512 session_id: session_id.clone(),
513 };
514
515 if let Some(panic_data_json) = serde_json::to_string_pretty(&panic_data).log_err() {
516 log::error!("{}", panic_data_json);
517 }
518
519 if !is_pty {
520 if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
521 let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
522 let panic_file_path = paths::LOGS_DIR.join(format!("zed-{}.panic", timestamp));
523 let panic_file = std::fs::OpenOptions::new()
524 .append(true)
525 .create(true)
526 .open(&panic_file_path)
527 .log_err();
528 if let Some(mut panic_file) = panic_file {
529 writeln!(&mut panic_file, "{}", panic_data_json).log_err();
530 panic_file.flush().log_err();
531 }
532 }
533 }
534
535 std::process::abort();
536 }));
537}
538
539fn upload_previous_panics(http: Arc<dyn HttpClient>, cx: &mut AppContext) {
540 let telemetry_settings = *client::TelemetrySettings::get_global(cx);
541
542 cx.background_executor()
543 .spawn(async move {
544 let panic_report_url = format!("{}/api/panic", &*client::ZED_SERVER_URL);
545 let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;
546 while let Some(child) = children.next().await {
547 let child = child?;
548 let child_path = child.path();
549
550 if child_path.extension() != Some(OsStr::new("panic")) {
551 continue;
552 }
553 let filename = if let Some(filename) = child_path.file_name() {
554 filename.to_string_lossy()
555 } else {
556 continue;
557 };
558
559 if !filename.starts_with("zed") {
560 continue;
561 }
562
563 if telemetry_settings.diagnostics {
564 let panic_file_content = smol::fs::read_to_string(&child_path)
565 .await
566 .context("error reading panic file")?;
567
568 let panic = serde_json::from_str(&panic_file_content)
569 .ok()
570 .or_else(|| {
571 panic_file_content
572 .lines()
573 .next()
574 .and_then(|line| serde_json::from_str(line).ok())
575 })
576 .unwrap_or_else(|| {
577 log::error!(
578 "failed to deserialize panic file {:?}",
579 panic_file_content
580 );
581 None
582 });
583
584 if let Some(panic) = panic {
585 let body = serde_json::to_string(&PanicRequest {
586 panic,
587 token: client::ZED_SECRET_CLIENT_TOKEN.into(),
588 })
589 .unwrap();
590
591 let request = Request::post(&panic_report_url)
592 .redirect_policy(isahc::config::RedirectPolicy::Follow)
593 .header("Content-Type", "application/json")
594 .body(body.into())?;
595 let response = http.send(request).await.context("error sending panic")?;
596 if !response.status().is_success() {
597 log::error!("Error uploading panic to server: {}", response.status());
598 }
599 }
600 }
601
602 // We've done what we can, delete the file
603 std::fs::remove_file(child_path)
604 .context("error removing panic")
605 .log_err();
606 }
607 Ok::<_, anyhow::Error>(())
608 })
609 .detach_and_log_err(cx);
610}
611
612async fn load_login_shell_environment() -> Result<()> {
613 let marker = "ZED_LOGIN_SHELL_START";
614 let shell = env::var("SHELL").context(
615 "SHELL environment variable is not assigned so we can't source login environment variables",
616 )?;
617 let output = Command::new(&shell)
618 .args(["-lic", &format!("echo {marker} && /usr/bin/env -0")])
619 .output()
620 .await
621 .context("failed to spawn login shell to source login environment variables")?;
622 if !output.status.success() {
623 Err(anyhow!("login shell exited with error"))?;
624 }
625
626 let stdout = String::from_utf8_lossy(&output.stdout);
627
628 if let Some(env_output_start) = stdout.find(marker) {
629 let env_output = &stdout[env_output_start + marker.len()..];
630 for line in env_output.split_terminator('\0') {
631 if let Some(separator_index) = line.find('=') {
632 let key = &line[..separator_index];
633 let value = &line[separator_index + 1..];
634 env::set_var(key, value);
635 }
636 }
637 log::info!(
638 "set environment variables from shell:{}, path:{}",
639 shell,
640 env::var("PATH").unwrap_or_default(),
641 );
642 }
643
644 Ok(())
645}
646
647fn stdout_is_a_pty() -> bool {
648 std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && std::io::stdout().is_terminal()
649}
650
651fn collect_url_args() -> Vec<String> {
652 env::args()
653 .skip(1)
654 .filter_map(|arg| match std::fs::canonicalize(Path::new(&arg)) {
655 Ok(path) => Some(format!("file://{}", path.to_string_lossy())),
656 Err(error) => {
657 if let Some(_) = parse_zed_link(&arg) {
658 Some(arg)
659 } else {
660 log::error!("error parsing path argument: {}", error);
661 None
662 }
663 }
664 })
665 .collect()
666}
667
668fn load_embedded_fonts(cx: &AppContext) {
669 let asset_source = cx.asset_source();
670 let font_paths = asset_source.list("fonts").unwrap();
671 let embedded_fonts = Mutex::new(Vec::new());
672 let executor = cx.background_executor();
673
674 executor.block(executor.scoped(|scope| {
675 for font_path in &font_paths {
676 if !font_path.ends_with(".ttf") {
677 continue;
678 }
679
680 scope.spawn(async {
681 let font_bytes = asset_source.load(font_path).unwrap().to_vec();
682 embedded_fonts.lock().push(Arc::from(font_bytes));
683 });
684 }
685 }));
686
687 cx.text_system()
688 .add_fonts(&embedded_fonts.into_inner())
689 .unwrap();
690}
691
692// #[cfg(debug_assertions)]
693// async fn watch_themes(fs: Arc<dyn Fs>, mut cx: AsyncAppContext) -> Option<()> {
694// let mut events = fs
695// .watch("styles/src".as_ref(), Duration::from_millis(100))
696// .await;
697// while (events.next().await).is_some() {
698// let output = Command::new("npm")
699// .current_dir("styles")
700// .args(["run", "build"])
701// .output()
702// .await
703// .log_err()?;
704// if output.status.success() {
705// cx.update(|cx| theme_selector::reload(cx))
706// } else {
707// eprintln!(
708// "build script failed {}",
709// String::from_utf8_lossy(&output.stderr)
710// );
711// }
712// }
713// Some(())
714// }
715
716// #[cfg(debug_assertions)]
717// async fn watch_languages(fs: Arc<dyn Fs>, languages: Arc<LanguageRegistry>) -> Option<()> {
718// let mut events = fs
719// .watch(
720// "crates/zed/src/languages".as_ref(),
721// Duration::from_millis(100),
722// )
723// .await;
724// while (events.next().await).is_some() {
725// languages.reload();
726// }
727// Some(())
728// }
729
730// #[cfg(debug_assertions)]
731// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {
732// cx.spawn(|mut cx| async move {
733// let mut events = fs
734// .watch(
735// "assets/icons/file_icons/file_types.json".as_ref(),
736// Duration::from_millis(100),
737// )
738// .await;
739// while (events.next().await).is_some() {
740// cx.update(|cx| {
741// cx.update_global(|file_types, _| {
742// *file_types = project_panel::file_associations::FileAssociations::new(Assets);
743// });
744// })
745// }
746// })
747// .detach()
748// }
749
750// #[cfg(not(debug_assertions))]
751// async fn watch_themes(_fs: Arc<dyn Fs>, _cx: AsyncAppContext) -> Option<()> {
752// None
753// }
754
755// #[cfg(not(debug_assertions))]
756// async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
757// None
758// }
759
760// #[cfg(not(debug_assertions))]
761// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
762
763pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] {
764 // &[
765 // ("Go to file", &file_finder::Toggle),
766 // ("Open command palette", &command_palette::Toggle),
767 // ("Open recent projects", &recent_projects::OpenRecent),
768 // ("Change your settings", &zed_actions::OpenSettings),
769 // ]
770 // todo!()
771 &[]
772}