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 if !urls.is_empty() {
212 listener.open_urls(urls)
213 }
214 } else {
215 upload_previous_panics(http.clone(), cx);
216
217 // TODO Development mode that forces the CLI mode usually runs Zed binary as is instead
218 // of an *app, hence gets no specific callbacks run. Emulate them here, if needed.
219 if std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_some()
220 && !listener.triggered.load(Ordering::Acquire)
221 {
222 listener.open_urls(collect_url_args())
223 }
224 }
225
226 let mut _triggered_authentication = false;
227
228 fn open_paths_and_log_errs(
229 paths: &[PathBuf],
230 app_state: &Arc<AppState>,
231 cx: &mut AppContext,
232 ) {
233 let task = workspace::open_paths(&paths, &app_state, None, cx);
234 cx.spawn(|cx| async move {
235 if let Some((_window, results)) = task.await.log_err() {
236 for result in results {
237 if let Some(Err(e)) = result {
238 log::error!("Error opening path: {}", e);
239 }
240 }
241 }
242 })
243 .detach();
244 }
245
246 match open_rx.try_next() {
247 Ok(Some(OpenRequest::Paths { paths })) => {
248 open_paths_and_log_errs(&paths, &app_state, cx)
249 }
250 Ok(Some(OpenRequest::CliConnection { connection })) => {
251 let app_state = app_state.clone();
252 cx.spawn(move |cx| handle_cli_connection(connection, app_state, cx))
253 .detach();
254 }
255 Ok(Some(OpenRequest::JoinChannel { channel_id: _ })) => {
256 todo!()
257 // triggered_authentication = true;
258 // let app_state = app_state.clone();
259 // let client = client.clone();
260 // cx.spawn(|mut cx| async move {
261 // // ignore errors here, we'll show a generic "not signed in"
262 // let _ = authenticate(client, &cx).await;
263 // cx.update(|cx| workspace::join_channel(channel_id, app_state, None, cx))
264 // .await
265 // })
266 // .detach_and_log_err(cx)
267 }
268 Ok(Some(OpenRequest::OpenChannelNotes { channel_id: _ })) => {
269 todo!()
270 }
271 Ok(None) | Err(_) => cx
272 .spawn({
273 let app_state = app_state.clone();
274 |cx| async move { restore_or_create_workspace(&app_state, cx).await }
275 })
276 .detach(),
277 }
278
279 let app_state = app_state.clone();
280 cx.spawn(|cx| async move {
281 while let Some(request) = open_rx.next().await {
282 match request {
283 OpenRequest::Paths { paths } => {
284 cx.update(|cx| open_paths_and_log_errs(&paths, &app_state, cx))
285 .ok();
286 }
287 OpenRequest::CliConnection { connection } => {
288 let app_state = app_state.clone();
289 cx.spawn(move |cx| {
290 handle_cli_connection(connection, app_state.clone(), cx)
291 })
292 .detach();
293 }
294 OpenRequest::JoinChannel { channel_id: _ } => {
295 todo!()
296 }
297 OpenRequest::OpenChannelNotes { channel_id: _ } => {
298 todo!()
299 }
300 }
301 }
302 })
303 .detach();
304
305 // if !triggered_authentication {
306 // cx.spawn(|cx| async move { authenticate(client, &cx).await })
307 // .detach_and_log_err(cx);
308 // }
309 });
310}
311
312// async fn authenticate(client: Arc<Client>, cx: &AsyncAppContext) -> Result<()> {
313// if stdout_is_a_pty() {
314// if client::IMPERSONATE_LOGIN.is_some() {
315// client.authenticate_and_connect(false, &cx).await?;
316// }
317// } else if client.has_keychain_credentials(&cx) {
318// client.authenticate_and_connect(true, &cx).await?;
319// }
320// Ok::<_, anyhow::Error>(())
321// }
322
323async fn installation_id() -> Result<String> {
324 let legacy_key_name = "device_id";
325
326 if let Ok(Some(installation_id)) = KEY_VALUE_STORE.read_kvp(legacy_key_name) {
327 Ok(installation_id)
328 } else {
329 let installation_id = Uuid::new_v4().to_string();
330
331 KEY_VALUE_STORE
332 .write_kvp(legacy_key_name.to_string(), installation_id.clone())
333 .await?;
334
335 Ok(installation_id)
336 }
337}
338
339async fn restore_or_create_workspace(app_state: &Arc<AppState>, mut cx: AsyncAppContext) {
340 async_maybe!({
341 if let Some(location) = workspace::last_opened_workspace_paths().await {
342 cx.update(|cx| workspace::open_paths(location.paths().as_ref(), app_state, None, cx))?
343 .await
344 .log_err();
345 } else if matches!(KEY_VALUE_STORE.read_kvp("******* THIS IS A BAD KEY PLEASE UNCOMMENT BELOW TO FIX THIS VERY LONG LINE *******"), Ok(None)) {
346 // todo!(welcome)
347 //} else if matches!(KEY_VALUE_STORE.read_kvp(FIRST_OPEN), Ok(None)) {
348 //todo!()
349 // cx.update(|cx| show_welcome_experience(app_state, cx));
350 } else {
351 cx.update(|cx| {
352 workspace::open_new(app_state, cx, |workspace, cx| {
353 // todo!(editor)
354 // Editor::new_file(workspace, &Default::default(), cx)
355 })
356 .detach();
357 })?;
358 }
359 anyhow::Ok(())
360 })
361 .await
362 .log_err();
363}
364
365fn init_paths() {
366 std::fs::create_dir_all(&*util::paths::CONFIG_DIR).expect("could not create config path");
367 std::fs::create_dir_all(&*util::paths::LANGUAGES_DIR).expect("could not create languages path");
368 std::fs::create_dir_all(&*util::paths::DB_DIR).expect("could not create database path");
369 std::fs::create_dir_all(&*util::paths::LOGS_DIR).expect("could not create logs path");
370}
371
372fn init_logger() {
373 if stdout_is_a_pty() {
374 env_logger::init();
375 } else {
376 let level = LevelFilter::Info;
377
378 // Prevent log file from becoming too large.
379 const KIB: u64 = 1024;
380 const MIB: u64 = 1024 * KIB;
381 const MAX_LOG_BYTES: u64 = MIB;
382 if std::fs::metadata(&*paths::LOG).map_or(false, |metadata| metadata.len() > MAX_LOG_BYTES)
383 {
384 let _ = std::fs::rename(&*paths::LOG, &*paths::OLD_LOG);
385 }
386
387 let log_file = OpenOptions::new()
388 .create(true)
389 .append(true)
390 .open(&*paths::LOG)
391 .expect("could not open logfile");
392
393 let config = ConfigBuilder::new()
394 .set_time_format_str("%Y-%m-%dT%T") //All timestamps are UTC
395 .build();
396
397 simplelog::WriteLogger::init(level, config, log_file).expect("could not initialize logger");
398 }
399}
400
401#[derive(Serialize, Deserialize)]
402struct LocationData {
403 file: String,
404 line: u32,
405}
406
407#[derive(Serialize, Deserialize)]
408struct Panic {
409 thread: String,
410 payload: String,
411 #[serde(skip_serializing_if = "Option::is_none")]
412 location_data: Option<LocationData>,
413 backtrace: Vec<String>,
414 app_version: String,
415 release_channel: String,
416 os_name: String,
417 os_version: Option<String>,
418 architecture: String,
419 panicked_on: u128,
420 #[serde(skip_serializing_if = "Option::is_none")]
421 installation_id: Option<String>,
422 session_id: String,
423}
424
425#[derive(Serialize)]
426struct PanicRequest {
427 panic: Panic,
428 token: String,
429}
430
431static PANIC_COUNT: AtomicU32 = AtomicU32::new(0);
432
433fn init_panic_hook(app: &App, installation_id: Option<String>, session_id: String) {
434 let is_pty = stdout_is_a_pty();
435 let app_metadata = app.metadata();
436
437 panic::set_hook(Box::new(move |info| {
438 let prior_panic_count = PANIC_COUNT.fetch_add(1, Ordering::SeqCst);
439 if prior_panic_count > 0 {
440 // Give the panic-ing thread time to write the panic file
441 loop {
442 std::thread::yield_now();
443 }
444 }
445
446 let thread = thread::current();
447 let thread_name = thread.name().unwrap_or("<unnamed>");
448
449 let payload = info
450 .payload()
451 .downcast_ref::<&str>()
452 .map(|s| s.to_string())
453 .or_else(|| info.payload().downcast_ref::<String>().map(|s| s.clone()))
454 .unwrap_or_else(|| "Box<Any>".to_string());
455
456 if *util::channel::RELEASE_CHANNEL == ReleaseChannel::Dev {
457 let location = info.location().unwrap();
458 let backtrace = Backtrace::new();
459 eprintln!(
460 "Thread {:?} panicked with {:?} at {}:{}:{}\n{:?}",
461 thread_name,
462 payload,
463 location.file(),
464 location.line(),
465 location.column(),
466 backtrace,
467 );
468 std::process::exit(-1);
469 }
470
471 let app_version = client::ZED_APP_VERSION
472 .or(app_metadata.app_version)
473 .map_or("dev".to_string(), |v| v.to_string());
474
475 let backtrace = Backtrace::new();
476 let mut backtrace = backtrace
477 .frames()
478 .iter()
479 .filter_map(|frame| Some(format!("{:#}", frame.symbols().first()?.name()?)))
480 .collect::<Vec<_>>();
481
482 // Strip out leading stack frames for rust panic-handling.
483 if let Some(ix) = backtrace
484 .iter()
485 .position(|name| name == "rust_begin_unwind")
486 {
487 backtrace.drain(0..=ix);
488 }
489
490 let panic_data = Panic {
491 thread: thread_name.into(),
492 payload: payload.into(),
493 location_data: info.location().map(|location| LocationData {
494 file: location.file().into(),
495 line: location.line(),
496 }),
497 app_version: app_version.clone(),
498 release_channel: RELEASE_CHANNEL.display_name().into(),
499 os_name: app_metadata.os_name.into(),
500 os_version: app_metadata
501 .os_version
502 .as_ref()
503 .map(SemanticVersion::to_string),
504 architecture: env::consts::ARCH.into(),
505 panicked_on: SystemTime::now()
506 .duration_since(UNIX_EPOCH)
507 .unwrap()
508 .as_millis(),
509 backtrace,
510 installation_id: installation_id.clone(),
511 session_id: session_id.clone(),
512 };
513
514 if let Some(panic_data_json) = serde_json::to_string_pretty(&panic_data).log_err() {
515 log::error!("{}", panic_data_json);
516 }
517
518 if !is_pty {
519 if let Some(panic_data_json) = serde_json::to_string(&panic_data).log_err() {
520 let timestamp = chrono::Utc::now().format("%Y_%m_%d %H_%M_%S").to_string();
521 let panic_file_path = paths::LOGS_DIR.join(format!("zed-{}.panic", timestamp));
522 let panic_file = std::fs::OpenOptions::new()
523 .append(true)
524 .create(true)
525 .open(&panic_file_path)
526 .log_err();
527 if let Some(mut panic_file) = panic_file {
528 writeln!(&mut panic_file, "{}", panic_data_json).log_err();
529 panic_file.flush().log_err();
530 }
531 }
532 }
533
534 std::process::abort();
535 }));
536}
537
538fn upload_previous_panics(http: Arc<dyn HttpClient>, cx: &mut AppContext) {
539 let telemetry_settings = *client::TelemetrySettings::get_global(cx);
540
541 cx.background_executor()
542 .spawn(async move {
543 let panic_report_url = format!("{}/api/panic", &*client::ZED_SERVER_URL);
544 let mut children = smol::fs::read_dir(&*paths::LOGS_DIR).await?;
545 while let Some(child) = children.next().await {
546 let child = child?;
547 let child_path = child.path();
548
549 if child_path.extension() != Some(OsStr::new("panic")) {
550 continue;
551 }
552 let filename = if let Some(filename) = child_path.file_name() {
553 filename.to_string_lossy()
554 } else {
555 continue;
556 };
557
558 if !filename.starts_with("zed") {
559 continue;
560 }
561
562 if telemetry_settings.diagnostics {
563 let panic_file_content = smol::fs::read_to_string(&child_path)
564 .await
565 .context("error reading panic file")?;
566
567 let panic = serde_json::from_str(&panic_file_content)
568 .ok()
569 .or_else(|| {
570 panic_file_content
571 .lines()
572 .next()
573 .and_then(|line| serde_json::from_str(line).ok())
574 })
575 .unwrap_or_else(|| {
576 log::error!(
577 "failed to deserialize panic file {:?}",
578 panic_file_content
579 );
580 None
581 });
582
583 if let Some(panic) = panic {
584 let body = serde_json::to_string(&PanicRequest {
585 panic,
586 token: client::ZED_SECRET_CLIENT_TOKEN.into(),
587 })
588 .unwrap();
589
590 let request = Request::post(&panic_report_url)
591 .redirect_policy(isahc::config::RedirectPolicy::Follow)
592 .header("Content-Type", "application/json")
593 .body(body.into())?;
594 let response = http.send(request).await.context("error sending panic")?;
595 if !response.status().is_success() {
596 log::error!("Error uploading panic to server: {}", response.status());
597 }
598 }
599 }
600
601 // We've done what we can, delete the file
602 std::fs::remove_file(child_path)
603 .context("error removing panic")
604 .log_err();
605 }
606 Ok::<_, anyhow::Error>(())
607 })
608 .detach_and_log_err(cx);
609}
610
611async fn load_login_shell_environment() -> Result<()> {
612 let marker = "ZED_LOGIN_SHELL_START";
613 let shell = env::var("SHELL").context(
614 "SHELL environment variable is not assigned so we can't source login environment variables",
615 )?;
616 let output = Command::new(&shell)
617 .args(["-lic", &format!("echo {marker} && /usr/bin/env -0")])
618 .output()
619 .await
620 .context("failed to spawn login shell to source login environment variables")?;
621 if !output.status.success() {
622 Err(anyhow!("login shell exited with error"))?;
623 }
624
625 let stdout = String::from_utf8_lossy(&output.stdout);
626
627 if let Some(env_output_start) = stdout.find(marker) {
628 let env_output = &stdout[env_output_start + marker.len()..];
629 for line in env_output.split_terminator('\0') {
630 if let Some(separator_index) = line.find('=') {
631 let key = &line[..separator_index];
632 let value = &line[separator_index + 1..];
633 env::set_var(key, value);
634 }
635 }
636 log::info!(
637 "set environment variables from shell:{}, path:{}",
638 shell,
639 env::var("PATH").unwrap_or_default(),
640 );
641 }
642
643 Ok(())
644}
645
646fn stdout_is_a_pty() -> bool {
647 std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && std::io::stdout().is_terminal()
648}
649
650fn collect_url_args() -> Vec<String> {
651 env::args()
652 .skip(1)
653 .filter_map(|arg| match std::fs::canonicalize(Path::new(&arg)) {
654 Ok(path) => Some(format!("file://{}", path.to_string_lossy())),
655 Err(error) => {
656 if let Some(_) = parse_zed_link(&arg) {
657 Some(arg)
658 } else {
659 log::error!("error parsing path argument: {}", error);
660 None
661 }
662 }
663 })
664 .collect()
665}
666
667fn load_embedded_fonts(cx: &AppContext) {
668 let asset_source = cx.asset_source();
669 let font_paths = asset_source.list("fonts").unwrap();
670 let embedded_fonts = Mutex::new(Vec::new());
671 let executor = cx.background_executor();
672
673 executor.block(executor.scoped(|scope| {
674 for font_path in &font_paths {
675 if !font_path.ends_with(".ttf") {
676 continue;
677 }
678
679 scope.spawn(async {
680 let font_bytes = asset_source.load(font_path).unwrap().to_vec();
681 embedded_fonts.lock().push(Arc::from(font_bytes));
682 });
683 }
684 }));
685
686 cx.text_system()
687 .add_fonts(&embedded_fonts.into_inner())
688 .unwrap();
689}
690
691// #[cfg(debug_assertions)]
692// async fn watch_themes(fs: Arc<dyn Fs>, mut cx: AsyncAppContext) -> Option<()> {
693// let mut events = fs
694// .watch("styles/src".as_ref(), Duration::from_millis(100))
695// .await;
696// while (events.next().await).is_some() {
697// let output = Command::new("npm")
698// .current_dir("styles")
699// .args(["run", "build"])
700// .output()
701// .await
702// .log_err()?;
703// if output.status.success() {
704// cx.update(|cx| theme_selector::reload(cx))
705// } else {
706// eprintln!(
707// "build script failed {}",
708// String::from_utf8_lossy(&output.stderr)
709// );
710// }
711// }
712// Some(())
713// }
714
715// #[cfg(debug_assertions)]
716// async fn watch_languages(fs: Arc<dyn Fs>, languages: Arc<LanguageRegistry>) -> Option<()> {
717// let mut events = fs
718// .watch(
719// "crates/zed/src/languages".as_ref(),
720// Duration::from_millis(100),
721// )
722// .await;
723// while (events.next().await).is_some() {
724// languages.reload();
725// }
726// Some(())
727// }
728
729// #[cfg(debug_assertions)]
730// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {
731// cx.spawn(|mut cx| async move {
732// let mut events = fs
733// .watch(
734// "assets/icons/file_icons/file_types.json".as_ref(),
735// Duration::from_millis(100),
736// )
737// .await;
738// while (events.next().await).is_some() {
739// cx.update(|cx| {
740// cx.update_global(|file_types, _| {
741// *file_types = project_panel::file_associations::FileAssociations::new(Assets);
742// });
743// })
744// }
745// })
746// .detach()
747// }
748
749// #[cfg(not(debug_assertions))]
750// async fn watch_themes(_fs: Arc<dyn Fs>, _cx: AsyncAppContext) -> Option<()> {
751// None
752// }
753
754// #[cfg(not(debug_assertions))]
755// async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
756// None
757// }
758
759// #[cfg(not(debug_assertions))]
760// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
761
762pub fn background_actions() -> &'static [(&'static str, &'static dyn Action)] {
763 // &[
764 // ("Go to file", &file_finder::Toggle),
765 // ("Open command palette", &command_palette::Toggle),
766 // ("Open recent projects", &recent_projects::OpenRecent),
767 // ("Change your settings", &zed_actions::OpenSettings),
768 // ]
769 // todo!()
770 &[]
771}