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