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