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